user31610
user31610

Reputation: 51

Using RewriteRules in httpd.conf

Everytime someone visits www.cars.com/parts I want them to be redirected to www.planes.com. After that the paths are the same. For example www.cars.com/parts/engine should go to www.planes.com/engine and www.cars.com/parts/wheels should go to www.planes.com/wheels and so forth. As of right now I have the following in my httpd.conf file:

 RewriteEngine on
 ServerName www.cars.com
 DocumentRoot /var/www/htdocs
 RewriteCond %{HTTP_HOST} www.cars.com/parts$ [NC]
 RewriteRule ^/(.*)$ www.planes.com$1 [R=301,L]

However, the problem is that www.cars.com/parts is taking me to www.planes.com/parts and not www.planes.com. Help would be much appreciated.

Upvotes: 0

Views: 58

Answers (1)

Dimitris Kalaitzis
Dimitris Kalaitzis

Reputation: 1426

Try changing the RewriteRule to :

 RewriteRule ^/parts(.*)$ www.planes.com$1 [R=301,L]

The $1 is substituted with the pattern detected in the parenthesis. So now it should append everything after /parts.

Upvotes: 1

Related Questions