301 redirects
-
How to redirect url to domain. eg. http://www.mydomain.com/index.php=HairThing → http://www.mydomain.com
-
How to redirect non-www to www WITHOUT the trailing slash?
+1
Pankaj
source
to share
3 answers
See also: Hidden mod_rewrite functions
#1
RewriteRule /index.php=HairThing$ http://www.mydomain.com [R=301]
#2
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule .* http://www.mydomain.com [R=301]
However, the case 1 example, as Greg said, will always include /
if it has no uri.
mydomain.com # impossible
mydomain.com/ # possible
mydomain.com/foo #possible
mydomain.com/foo/ #possible
+4
source to share
you can use a general rule that works in every domain without having to change the domain name all the time. This is very useful if you have multiple domains parked on the same root.
RewriteCond %{HTTP_HOST} !^www\.[a-z0-9-]+\.[a-z]{2,6} [NC]
RewriteCond %{HTTP_HOST} ([a-z0-9-]+\.[a-z]{2,6})$ [NC]
RewriteRule (.*) http://www.%1/$1 [L,R=301]
0
source to share