Link to home
Start Free TrialLog in
Avatar of wardjame
wardjame

asked on

htaccess redirect with or without www to static page

I need to redirect a new domain to a static page within an existing domain.  Here is the code I am using right now that appears to work ok:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.newdomain.com
RewriteRule (.*) http://www.olddomain.com/page.html [R=301,L]

Open in new window


I would like to change this code so it will work with or without the www before newdomain.com
ASKER CERTIFIED SOLUTION
Avatar of farzanj
farzanj
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wardjame
wardjame

ASKER

@farzanj
Won't that mean it will only work without www and not with?  I need both to work.
I don't have system to test it right now.  I have removed ^ as well.  It should work with both.  Otherwise, you can get rid of the RewriteCond completely.  That would do it.