Tom Senner
Tom Senner

Reputation: 548

redirect 301 - One htaccess for multiple websites

I'm having one htaccess file that is used by multiple websites and have trouble redirecting directories for one specific domain only.

Example:
I would like
www.website.com/folder to redirect 301 to www.website.com/NEWfolder but at the same time NOT redirect www.website-2.com/folder.

Is this possible?

Upvotes: 0

Views: 94

Answers (1)

Jon Lin
Jon Lin

Reputation: 143896

Assuming that all these sites are served from the same document root, you'll need mod_rewrite's %{HTTP_HOST} variable to narrow down the site that you want to focus on:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?website\.com$ [NC]
RewriteRule ^folder/(.*)$ /NEWfolder/$1 [L,R=301]

Upvotes: 0

Related Questions