I've two domain names within the format of foo.com and foo.internet. I presently possess the following during my .htaccess to redirect non-world wide web to world wide web:
# Rewrite Hyperlink to pressure World wide web RewriteCond % ^[^.]*.[^.]*$ RewriteCond % !=443 RewriteRule ^ http://world wide web.%% [R=301,L] RewriteCond % ^[^.]*.[^.]*$ RewriteCond % =443 RewriteRule ^ https://world wide web.%% [R=301,L] RewriteCond % ^www.(.*.[^.]*.[^.]*)$ [NC] RewriteCond % !=443 RewriteRule ^ http://%1% [R=301,L] RewriteCond % ^www.(.*.[^.]*.[^.]*)$ [NC] RewriteCond % =443 RewriteRule ^ https://%1% [R=301,L]
However, I wish to redirect Web addresses ending insinternet to visit .com, such as the subdomains. Good examples:
foo.internet -> foo.com
world wide web.foo.internet -> world wide web.foo.com
foo.internet/bar -> foo.com/bar
sub.foo.internet -> sub.foo.com
sub.foo.internet/bar -> sub.foo.com/bar
I previously had this on another site, however it was years back and that i not have the .htaccess any longer. Does anybody know a good way to do this?
Edit: This is actually the relaxation from the .htaccess:
# BEGIN WordPress # RewriteEngine on # # Unless of course you've set another RewriteBase preceding this time, # you might remove or comment-the following RewriteBase directive # RewriteBase / # # if the request is perfect for "/" or was already rewritten to Wordpress RewriteCond $1 ^(index.php)?$ [OR] # or maybe request is perfect for image, css, or js file RewriteCond $-(presendigitalpngphpicocssjs)$ [NC,OR] # or maybe URL resolves to existing file RewriteCond % -f [OR] # or maybe URL resolves to existing directory RewriteCond % -d # then skip the rewrite to Wordpress RewriteRule ^(.*)$ - [S=1] # else rewrite the request to Wordpress RewriteRule . /index.php [L] # # Finish wordpress # Rewrite Hyperlink to pressure World wide web -(see surface of publish)-
Disregarding the truth that this really is undoubtedly probably the most devilish rewrite ruleset that I have ever written, this remarkably appears to consider proper care of that which you presently have, plus what you would like, inside a nice, compact package.
Tell me for those who have any issues with it:
RewriteCond % =on RewriteRule .* - [E=RW_HTTPS:s] RewriteCond % ^www.(.*.[^.]*.[^.]*)$ [NC,OR] RewriteCond world wide web.% ^(www.[^.]*.[^.]*)$ RewriteRule .* - [E=RW_THOST:%1] RewriteCond % ^(.*).(internetcom)$ [NC,OR] RewriteCond % ^(.*).internet$ [NC] RewriteRule .* http%://%1.com% [R=301,L]