Strange redirects

You are here:
Estimated reading time: 1 min

If you have strange URLs in your analytics or you can see that the site redirects to an URL like this:
https://www.yoursite.com/wp-content/cache/yoursite.com/desktop/unauthenticated/index.html

This is probably caused by an improper order of htaccess rules. Probably you are using a force SSL or force www/non-www rule in .htaccess. Please remove these rules from .htaccess, and insert them in

Settings→General→Tweaks: Custom .htaccess

or at least at the top of the .htaccess file. We suggest not to use the Really Simple SSL or similar redirect plugins. This can cause (too) many unwanted redirects. This method requires manual troubleshooting, but it is more effective and better for performance.

Some examples:

# Redirect non-www to (ssl) www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]
# Redirect non-SSL to SSL
RewriteCond %{HTTPS} !on
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

# Redirect www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.example\.com [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
Was this article helpful?
Dislike 0 4 of 4 found this article helpful.
Views: 610