WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] WP Super Cache / Images not displaying (8 posts)

  1. fairywitch
    Member
    Posted 5 years ago #

    I have posted a question at my host's forum but have not really received any help so far, except that maybe Super Cache & my htaccess rules may not play nice together. I have (and always had) rules to stop hotlinkers and up until the past couple of weeks or so, they worked just fine and the Super Cache was also working just fine. Every time I have visited my sites in the past 2 weeks or so, the images are not showing up. Yesterday I took out the rules for hotlinking and the images came up fine with Super Cache turned on. I had tried emptying the Super Cache manually, and strangely enough, the images were back - but only until the next time I emptied my browser's cache and visited again.

    Is there a remote possibility that my htaccess rules & Super Cache aren't working together for some reason?

    These are my hotlinking rules:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?fairywitch.net/.*$ [NC,OR]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?beewitched.fairywitch.net/.*$ [NC,OR]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?fairywitchsims.com/.*$ [NC]
    RewriteRule .*\.(jpg|jpeg|gif|png|bmp|rar|zip)$ - [F]

    I have this problem on both my self-hosted WordPress sites. Plugins and WordPress are all updated to the latest versions.

    The pages seem to be cacheing ok btw; the notice about the cached page is always at the bottom of my page when I view the source.

    Thanks for your time & help. =)

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Post the whole set of rules. Can't debug with only a partial.

    Enclose the rules between backticks as well, if you would.

  3. fairywitch
    Member
    Posted 5 years ago #

    OK - It's pretty long. My sites have worked for over a year with this configuration though. Oh, and tell me what you mean with "backticks"?

    Here you go:

    suPHP_ConfigPath /home/xxxxxxxx/public_html
    DirectoryIndex index.php index.html
    Options All -Indexes
    Options +FollowSymLinks
    
    <Files .htacess>
    order allow,deny
    deny from all
    </Files>
    
    <Files php.ini>
    order allow,deny
    deny from all
    </Files>
    
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^$
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?fairywitch.net/.*$ [NC,OR]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?beewitched.fairywitch.net/.*$ [NC,OR]
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?fairywitchsims.com/.*$ [NC]
    RewriteRule \.(jpg|jpeg|gif|png|bmp|rar|zip)$ - [F]
    
    // edit by mod: Whole bunch of irrelevant bot blocking stuff was here...
    
    # Begin - Rewrite rules to block out some common exploits
    # Block out any script trying to base64_encode crap to send via URL
    RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
    # Block out any script that includes a <script> tag in URL
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
    # Block out any script trying to set a PHP GLOBALS variable via URL
    RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
    # Block out any script trying to modify a _REQUEST variable via URL
    RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
    # Send all blocked request to homepage with 403 Forbidden error!
    RewriteRule ^(.*)$ index.php [F,L]
    # End - Rewrite rules to block out some common exploits
    
    # BEGIN WPSuperCache
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    AddDefaultCharset UTF-8
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{QUERY_STRING} !.*attachment_id=.*
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|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 %{REQUEST_METHOD} !=POST
    RewriteCond %{QUERY_STRING} !.*s=.*
    RewriteCond %{QUERY_STRING} !.*attachment_id=.*
    RewriteCond %{HTTP_COOKIE} !^.*(comment_author_|wordpress|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]
    </IfModule>
    # END WPSuperCache
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Edit by mod: Code-ified

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Look at the bottom of the post box on this forum, where it says:
    Put code in between backticks.

    Those are backticks, and it's how we put code in.

  5. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    Also, try changing this:
    RewriteRule \.(jpg|jpeg|gif|png|bmp|rar|zip)$ - [F]

    To this:
    RewriteRule \.(jpg|jpeg|gif|png|bmp|rar|zip)$ - [F,L]

  6. fairywitch
    Member
    Posted 5 years ago #

    Sorry, seems I didn't look further than my own nose when posting...

    I tried your suggestion. It didn't work, unfortunately. Are there any other things I could try?

    I am going to have to remove the rules for hotlinking in the meantime if I can't get it to work because my websites don't work without images. It's just strange though that this started a couple of weeks back. Maybe it has something to do with 2.6. =/

  7. Samuel Wood (Otto)
    Tech Ninja
    Posted 5 years ago #

    After you try my suggestion, make sure that you clear your super cache afterwards and leave the changed rule there.

    If I'm correct, then the cache is caching something it shouldn't be. So you won't see any instant impact from my rule change, you'll need to clear the cache first and reload a few times to see if it's fixed.

  8. fairywitch
    Member
    Posted 5 years ago #

    I did do what you said, Otto. It wasn't working though up until I did a few more things.

    It is *resolved* - and I hope it is fixed for good. Both sites display images now. There was an update to WP Super Cache which I immediately used. Also, my host's support line said that I should turn off CPanel's Hotlink Protection. I turned it on 2 years ago almost and never looked at it again because I have been basically making my own and after looking in there again, it seems very different to when I last looked at it! Support said it might have been conflicting. I did change the conditions & rule somewhat aswell. I don't know which one of those things did the trick, or, if all 3 did it together.

    Thanks for your help. =)

Topic Closed

This topic has been closed to new replies.

About this Topic