0

We have rebuild our site and are looking to redirect about 1000 URLs. Looking around on the web it seems

Redirect 301 /oldlocation http://www.domain2.com/newlocation

is the string to use. I just wonder how the server knows the domain of /oldlocation as it hosts more then one website. If we have two websites with /oldlocation will both be redirected?

Is it possible to use

Redirect 301 http:full-old-url http:new-url

instead to make sure the server knows what old URL we are targeting?

Micah Elliott
  • 9,600
  • 5
  • 51
  • 54
Makkie
  • 1
  • Either put your .htaccess file in the folder of just the domain you require, or configure it in the relevant server block in your config file. [Here's a SO question explaining how to do this with virtual hosts.](http://stackoverflow.com/questions/10175513/mod-rewrite-in-vhosts-configuration) – samiles Feb 10 '17 at 14:58

1 Answers1

0

In Redirect directive's pattern ,you can match against the URI (url part after the hostname) ,not the host. To match against HOST, you will need to use mod-rewrite.

RewriteEngine on

RewriteCond %{HTTP_HOST} example1.com
RewriteRule ^/?oldpath http://example2.com/newpath [L,R=301]

The example above will redirect all requests from example1.com/oldpath to example2.com/newpath .

Amit Verma
  • 40,709
  • 21
  • 93
  • 115