Reputation: 9055
I have a sub folder /blog
hosting my blog and the root hosting the application. I have couple of domains which are targeting my root. I would like to redirect with .htaccees all the request on sub folder blog to given domain
domain1
domain2
domain3
each touching root
if request
domain1/blog
domain2/blog
than redirect to domain3/blog
What I try
RewriteCond %{HTTP_HOST} domain\.de(.*)|domain1\.de(.*)|domain2\.com(.*)|domain3\.de(.*)
RewriteRule (.*) http\://www\.domain4\.com/blog/$1 [R=301]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{HTTP_HOST} !domain4\.com$ [NC]
RewriteRule ^blog/(.*)$ http://www.domain4/blog/$1 [L,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Upvotes: 0
Views: 28
Reputation: 143906
you could just invert the condition using a !
:
RewriteCond %{HTTP_HOST} !domain4\.com$ [NC]
RewriteRule ^(.*)$ http://domain4.com/blog/$1 [L,R=301]
Upvotes: 1