Temporarily disable cache? Or, just append to all PHP files

Giganews Newsgroups
Subject: Temporarily disable cache? Or, just append to all PHP files
Posted by:  jwcarlton (jwcarlt…@gmail.com)
Date: Sat, 3 Sep 2011

Last night, I updated Apache using /scripts/easyapache, but for some
reason it killed PHP. So for about 20 minutes, anyone on the site was
downloading honest-to-God source code when they went to a page!

Tragic, I know.

I was able to fix the problem by recompiling to an earlier PHP
version, but then today I had several emails from people that are
still downloading source code. It looks like, if they were on the site
at all last night, then their cache is still having them download code
instead of seeing the page.

So, I'm trying to bypass cache in .htaccess for all users,
temporarily. My plan is this, but it's not doing anything:

# Append "z=1", temporary
RewriteCond %{SCRIPT_NAME} index.php [NC]
RewriteCond %{QUERY_STRING} !z=1
RewriteRule ^(.*)$ /$1?z=1 [R=301,QSA]

IIRC, this should mean "if SCRIPT_NAME contains index.php (ignore
case), and QUERY_STRING doesn't already contain z=1, then redirect any
page to itself + ?z=1, then append the rest of QUERY_STRING to the
end.

But I'm getting no redirects at all from this. What am I overlooking?
I'm not even really sure if this would work, but I know that if I
manually go to www.mydomain.com/?z=1, it comes up, but if I just go to
www.mydomain.com, I get the download.

There is more to the htaccess file, if you want to see it in context:

RewriteEngine On
Options -Indexes

# Force www and trailing /
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteCond %{HTTP_HOST} !^images [NC]
RewriteRule (.*) http://www\.%{HTTP_HOST}%{REQUEST_URI} [R=301,QSA]

RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+[^/])$ $1/ [R=301,QSA]

# Append "z=1", temporary
RewriteCond %{SCRIPT_NAME} index.php [NC]
RewriteCond %{QUERY_STRING} !z=1
RewriteRule ^(.*)$ /$1?z=1 [R=301,QSA]

## Redirect Old Pages
RewriteCond %{REQUEST_URI} ^/contact [NC]
RewriteRule ^contact/(.*) /services/contact/$1 [R=301,QSA,L]

RewriteCond %{REQUEST_URI} ^/faq [NC]
RewriteRule ^faq/(.*) /services/faq/$1 [R=301,QSA,L]

ANY help at all would be greatly appreciated! TIA,

Jason

Replies