Forum Moderators: phranque
I've parked old_domain.com => new_domain.com, and also need the old_domain to redirect to new_domain.com in the browser window.
What I put in .htaccess (below) works great for non-"www" requests to old-domain.com, but does not redirect www.old_domain.com in the browser window to www.new_domain.com.
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^old_domain\.com
RewriteRule ^(.*)$ [new_domain.com...] [R=301,L]
I've tried to add the www to RewriteCond, such as ^www\.old_domain\.com , but it still won't redirect both www and non-www requests.
Is there a way to redirect both WWW and non-WWW requests using mod rewrite?
Thanks,
Eric
You could make the www in the condition optional:
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.com
or, if the only requests that your .htaccess file will 'catch' are for the old domain, you could remove the condition entirely:
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http//www.new_domain.com/$1 [R=301,L]
'?' matches the preceding character or group of characters 0 or 1 time.
Hope this helps.
Justin
Thank you for the quick reply .. works like a charm!
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?old_domain\.com [NC]
RewriteRule ^(.*)$ [new_domain.com...] [R=301,L]
Kind regards,
Eric
<snip>
[edited by: jdMorgan at 8:12 pm (utc) on April 27, 2005]
[edit reason] Removed tag line per TOS. [/edit]