For our development server I have an interface where people can add their IP temporarily to the list of allowed IPs. If someone tries to access an url from an IP that is not on the list, it is redirected to the IP add interface. But once the IP is added, the original url that was requested still redirects to the interface (the browser cached the redirect, this is confusing for our clients).
The redirect is done by specifying an ErrorDocument. Can I force an uncache to it?
my .htaccess in the root:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(!www\.)?(.+)
RewriteCond %{HTTP_HOST} ^(.*)\.SITENAME\.com
RewriteRule ^(.*)$ http://SITENAME.com/%1/$1 [L,P,NC,QSA]
#####
ErrorDocument 403 http://xs.SITENAME.com
order deny,allow
deny from all
allow from 12.345.678.90 #1389452253
allow from 12.345.678.91 #1389461806
allow from 12.345.678.92 #1389486472
allow from 12.345.678.93 #1389550179
allow from 12.345.678.94 #1389618643
EDIT: The accepted answer seemed to work in the first place, but in some occasions for some reason it didn't. The best solution happened to be to change the .htaccess every time when somebody is redirected to the error page. (Open the .htaccess, change a comment line to #random_string (unix time, for instance)) This makes the browser re-examine .htaccess
You could try using these rules, but unfortunately if a browser decides to cache a request, there isn't anything we can do to force it not to.
FileETag None
<IfModule mod_headers.c>
Header unset ETag
Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"
</IfModule>
You can also wrap those rules inside a <FilesMatch>
or <Files>
to target only one or a few URLs:
<FilesMatch "\.(htm|html)$">
# The rules from above
</FilesMatch>
<Files index.php>
# The rules from above
</Files>