重定向包含更多域的子文件夹

时间:2014-05-27 13:55:48

标签: apache .htaccess redirect

我有一个子文件夹/blog托管我的博客和托管该应用程序的根。我有几个针对我的根目录的域名。我想将.htaccees子文件夹博客上的所有请求重定向到给定域

domain1
domain2
domain3

每个感人的根

如果请求

domain1/blog

domain2/blog

而不是重定向到domain3/blog

我尝试了什么

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>

1 个答案:

答案 0 :(得分:1)

您可以使用!

反转条件
RewriteCond %{HTTP_HOST} !domain4\.com$ [NC]
RewriteRule ^(.*)$ http://domain4.com/blog/$1 [L,R=301]
相关问题