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

htaccess rewrite all domains to new domain

Hello,

I have 40 domains that point to one domain but they keep their domain names in tact, I want to change that.

Currently I have it so:
domain1.com
domain2.com
domain3.com

show their domain names but actually load
domain.com

I want the htacess to say
if domain.com then nothing, if not domain.com then change the domain name to domain.com and leave the other info in the url

ie
if domain1.com/search/test.php
then rewrite domain.com/search/test.php
0
movieprodw
Asked:
movieprodw
  • 3
  • 3
1 Solution
 
Mark BullockQA Engineer IIICommented:
Put this in the VirtualHost for each domain you want to redirect.
RewriteRule  ^/(.*)  http://domain.com/$1  [R,L]

Open in new window

0
 
movieprodwAuthor Commented:
what if they all use the same htacess, will that create a loop?
0
 
Mark BullockQA Engineer IIICommented:
No. You will not have this rewrite rule in the VirtualHost for domain.com.
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
movieprodwAuthor Commented:
Okay, but I don't have a vitualhost for them, they are just pointed by dns, so there is only one htacess file and one index.php file so I need to make it so if it is domain.com then great, if not then redirect to domain.com/xxxx
0
 
Mark BullockQA Engineer IIICommented:
You can add a rewrite condition.
RewriteCond %{HTTP_HOST} ^www.domain\d.com$
RewriteRule  ^/(.*)  http://domain.com/$1  [R,L]

Open in new window

0
 
movieprodwAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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