Apparently there are nocache rules that can be added to .htaccess for temporary redirects, such as while updating a live WP site. In researching a difficulty with my browser getting "stuck" in a redirect to my staging site, I found an article about cache control with mod_rewrite that talks about this very issue.

I'm using Softaculous WordPress Manager to push changes from staging to live, and it modifies RewriteConds in .htaccess for the few minutes it takes to run the operations then changes them back.

Would adding some of the lines from the referenced article to my .htaccess (permanently) work in conjunction with temporary modifications Softaculous makes to tell browsers not to "remember" those redirects? If so, which ones?

Here's my current .htaccess:

# BEGIN WordPress

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

RewriteCond %{HTTP_REFERER} !^https://example.org/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^https://example.org$      [NC]
RewriteCond %{HTTP_REFERER} !^http://example.org/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://example.org$      [NC]
... (lots of other variations with subdomains)

I viewed this file during a push to live and I believe Softaculous simply added the staging site's subdomain to the RewriteConds:

RewriteCond %{HTTP_REFERER} !^https://dev.example.org/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^https://dev.example.org$      [NC]
RewriteCond %{HTTP_REFERER} !^http://dev.example.org/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://dev.example.org$      [NC]
  • Suggestion from Softaculous: "Which cache plugin do you use ? Is WP_CACHE set to true in your wp-config.php ? If yes please check if WP_SALT is also defined in your wp-config.php if not please set WP_SALT in config files with their URLs as the value and check if you still face the issue." I'm not sure what the salts have to do with redirects, but the 8 salts are defined in wp-config, there is no caching plugin, and WP_CACHE is not set. – Rickmakeitquick Apr 8 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.