• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

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
0
wardjame
Asked:
wardjame
  • 2
1 Solution
 
farzanjCommented:
You should modify RewriteCond.
RewriteCond %{HTTP_HOST} newdomain.com

Does that work for you?
0
 
wardjameAuthor Commented:
@farzanj
Won't that mean it will only work without www and not with?  I need both to work.
0
 
farzanjCommented:
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.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now