Good Afternoon,
A year ago I migrated my domain name to a domain I had purchased. I have kept the old domain active for the purpose of handling the custom 301's for nearly 5000 links that were changed during migration. While 95% of the URLs are being redirected properly I am finding that my rewrite rules in htaccess aren't catching everything. I've researched and tested many different variations with no luck, I'm hoping someone can help.
** Remember that my rewrite rules are meant to format the old links before they are eventually redirected to the correct URL on the new domain.
My current rewrite rules are:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTPS} off [NC]
RewriteRule ^(.*)/$ $1 [R=301,L]
RewriteRule ^(.*)RK= /$1 [L,NC,R=301]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)$ http://newdomain.com/? [R=301,L]
RewriteCond %{REQUEST_URI} ^/$
Rewriterule ^(.*)$ http://newdomain.com/ [L,R=301]
Again, I'm certainly not an htaccess/Apache expert, I've just compiled this list through a lot of trial and error over the past year. The goal of the rewrite rules is:
To rewrite any https to http:
RewriteCond %{HTTPS} on [OR]
RewriteCond %{HTTPS} off [NC]
To remove the trailing slash if present:
RewriteRule ^(.*)/$ $1 [R=301,L]
To remove code associated with hacking attempts that attach themselves to the end of certain URLs and look like /RK=0/RS=****:
RewriteRule ^(.*)RK= /$1 [L,NC,R=301]
To remove any references to index.php within the URL:
RewriteCond %{THE_REQUEST} ^.*/index.php
Once these rewrite rules have been applied then link is then redirected based on my 301 link map. As of today these rewrite rules are pretty effective with the exception of the https to http redirect. For whatever reason I cannot get that rule to apply, so any inbound link with https stalls on the "Your connection is not private" screen and does not redirect. Any suggestions on how to have the https to http rule work correctly?