We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

htaccess redirect with or without www to static page

wardjame
wardjame asked
on
Medium Priority
407 Views
Last Modified: 2012-05-11
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
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
@farzanj
Won't that mean it will only work without www and not with?  I need both to work.
CERTIFIED EXPERT

Commented:
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.