How do i redirect a url to domain . eg. http://www.mydomain.com/index.php=HairThing --> http://www.mydomain.com
How do i redirect a non-www to www WITHOUT a slash at end ?
views:
139answers:
3
+2
A:
For your second question, the browser will always put a slash after the site name. This is because the trailing slash is required to indicate the root path of the web site.
Greg Hewgill
2008-12-10 07:21:37
+3
A:
See also: http://stackoverflow.com/questions/286004/hidden-features-of-modrewrite
#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, example case 1, as said by Greg, will always put the /
on if it is without a uri.
mydomain.com # impossible
mydomain.com/ # possible
mydomain.com/foo #possible
mydomain.com/foo/ #possible
Kent Fredric
2008-12-10 07:22:04
A:
you could use a general rule that works on every domain without having to change the name of the domain all the time. This is very helpful when you have multiple domains parked on 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]
solomongaby
2009-04-01 11:32:11