The_Fox

msg:4373308 | 4:46 pm on Oct 11, 2011 (gmt 0) |
Try this. Make sure you take backups.
Options +FollowSymlinks RewriteEngine on RewriteCond %{HTTP_HOST} ^uglydomain\.com [OR] RewriteCond %{HTTP_HOST} ^www\.uglydomain\.com RewriteCond %{HTTP_HOST} uglydomain\.com RewriteRule (.*) http://www.prettydomain.com/$1 [R=301,L] [edited by: The_Fox at 4:48 pm (utc) on Oct 11, 2011]
|
The_Fox

msg:4373309 | 4:47 pm on Oct 11, 2011 (gmt 0) |
Can you also share the URl structure for the old and new domains? I assume they are the same.
|
ArielZusya

msg:4373314 | 4:54 pm on Oct 11, 2011 (gmt 0) |
That did it. Thanks!
|
lucy24

msg:4373399 | 9:17 pm on Oct 11, 2011 (gmt 0) |
Fox, can you explain this part? RewriteCond %{HTTP_HOST} ^uglydomain\.com [OR] RewriteCond %{HTTP_HOST} ^www\.uglydomain\.com RewriteCond %{HTTP_HOST} uglydomain\.com It seems redundant, but obviously it isn't if the effect is different from the version without the third line. btw, it should be possible to express the [OR] pair as (www\.)?uglydomain\.com
|
g1smd

msg:4373410 | 9:45 pm on Oct 11, 2011 (gmt 0) |
This is more robust.
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$ RewriteRule (.*) http://www.example.com/$1 [R=301,L] Redirect if requested hostname is not "exactly" www.example.com Make sure you escape any literal periods in all RegEx patterns.
|
phranque

msg:4373856 | 12:54 am on Oct 13, 2011 (gmt 0) |
!^(www\.example\.com)?$
the '?' after the ')' makes the capture group optional, so hidden in g1smd's regexp is that it also matches when HTTP_HOST is exactly null. this is a good thing as it handles the special case of HTTP/1.0 user agent requests. HTTP_HOST for HTTP/1.0 browser: http://www.webmasterworld.com/forum92/2240.htm [webmasterworld.com]
|
|