Cowboy Programming Game Development and General Hacking by the Old West

August 18, 2008

CPanel Hotlink Protection Breaks WP Permalinks

Filed under: Game Development — Mick West @ 9:08 pm

I was messing with the hotlink protection in CPanel, and just toggled it on and off, unfortunately this broke the permalinks in wordpress. Specifically it removed the line:

RewriteEngine On

In .htaccess

Took me a while to track down.

With wp-supercache, the mod_rewrite part of your .htaccess should look like:

<IfModule mod_rewrite.c>
# BEGIN WordPress

RewriteEngine On
RewriteBase /
#RewriteCond %{QUERY_STRING} !.*s=.*
#RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
#RewriteCond %{HTTP_COOKIE} !^.*wordpress.*$
#RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
#RewriteCond %{HTTP:Accept-Encoding} gzip
#RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz -f
#RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html.gz [L]

#RewriteCond %{QUERY_STRING} !.*s=.*
#RewriteCond %{HTTP_COOKIE} !^.*comment_author_.*$
#RewriteCond %{HTTP_COOKIE} !^.*wordpress.*$
#RewriteCond %{HTTP_COOKIE} !^.*wp-postpass_.*$
#RewriteCond %{DOCUMENT_ROOT}/wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html -f
#RewriteRule ^(.*) /wp-content/cache/supercache/%{HTTP_HOST}/$1/index.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

In my case the “RewriteEngine On” was missing, causing individual pages not to work, but the main page worked fine, so I did not notice.


  1. I don’t use Cpanel – I use Plesk on my web server.
    I had a similar issue once whne I was trying to modify my .htaccess file to set up a 301 re-direct.
    That’s when I learned about the Apache mod_rewrite and that it has to be enabled to make any changes to the .htaccess.
    Thanks for your info!

    Comment by Branson Computer Repair — December 7, 2008 @ 3:46 am

  2. ohh.. thanks a lot. I have had this problem myself, but couldn’t figure it out.

    Comment by The Empyrean review — December 9, 2008 @ 3:47 am

  3. Thanks for pointing out the code. I too like to play, and often end up breaking stuff!

    How are you liking WP2.7? It was just released, and they are already starting on 2.8…

    Comment by clean red widgets — December 24, 2008 @ 3:30 pm

  4. You know, I had a problem like this once, and the guys over at Hostgator helped me out. Ive been very fortunate to have them to help me out and get me out of the messes I get into every so often!

    Comment by Sandy — January 13, 2009 @ 12:50 am

  5. Do you think the “RewriteEngine On” missing will cause any problems down the line? It may not be something that you notice right away.

    Comment by Clean Red Widgets — January 13, 2009 @ 4:31 am

  6. Agree with Sandy. Hostgator has helped me get out of this problem and many others with wordpress.

    Comment by Bodybuilding — January 16, 2009 @ 3:11 pm

  7. Problems like that drive me crazy. I had a template problem,while my main index looked the same, the page posts were all messed up. I rarely check those, finally when I did, I freaked. I think it was messed up for 2 months!

    Comment by Air Duct Cleaners Atlanta — January 24, 2009 @ 4:35 pm

  8. Yeah I had a similar problem but hostgator helped me out. Two months is a crazy time to deal with a problem like that, mine was done in just a couple days.

    Comment by Suffolk Auto — March 7, 2009 @ 3:51 pm

  9. What’s all the lines commented out?

    Comment by Anonymous — March 16, 2009 @ 9:20 am

  10. Thanks so much for putting this up – it’s just solved a major headache of mine!

    Comment by Freelance programmer — March 30, 2009 @ 2:38 am

  11. yikes. that looks like a lot of work. Better that I don’t touch those features in cpanel that I’m now aware of. Don’t wanna brake my wordpress cause I probably don’t know how to fix it or search for the bug.

    Comment by kotiteatteri — May 3, 2009 @ 11:45 pm

  12. One thing about cpanel is that it writes to .htaccess file if you change certain settings, configurations, or extras using cpanel. Sometimes it messes up and doesn’t write to .htaccess right or will even overwrite what you have there. If you are comfortable with it, I would manually edit the .htaccess file to apply changes rather than use cpanel. If you are not comfortable with it. Download your .htaccess file first, then make the changes with cpanel. If it messes up you can simply upload the original/before the changes back. Or compare the differences to see what the problem might be.

    Comment by Domain Reviews — May 12, 2009 @ 11:49 pm

  13. Seen WP2.8 yet? I just updated and it has a pretty nice interface. Only problem is it has a bug in how it reads shortcode, so my wp columns plugin is completely messed up. Now I have to go through and add spaces in the shortcode because 2.8 can’t read it otherwise…stupid coding issues…

    Comment by Spanish Fork Mechanic — July 7, 2009 @ 12:58 pm

  14. is this working with the new wordpress release ?
    i dont understand much from mod rewrite.

    Comment by motorsport — August 18, 2009 @ 12:49 pm

  15. It’s not really a WordPress bug, it’s a problem with CPanel.

    Comment by Mick West — August 18, 2009 @ 1:22 pm

  16. Yes well I agree with Mick West, it seems to be a CPANEL bug.

    Comment by xt Commerce Templates — August 19, 2009 @ 2:20 am

  17. I think they fixed this problem in the most recent version of CPanel. Might be me but it looks like they dropped the hotlink function entirely.

    Comment by thuiswerk — September 27, 2009 @ 4:11 am

  18. I had this problem before. I turned on hotlink protection recently as I had some issues and was afraid to turn it off (still am) even though ti appears to be working. Before I had the same issue. All pages but my main page vanished. No good luck with any of the WP plugins to stop HLing. Messed my site up even worse usually.



    Comment by Bill — December 29, 2009 @ 10:38 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress