Root重定向到.htaccess中的一个子域

时间:2016-06-29 16:16:26

标签: .htaccess redirect subdomain multisite

我希望我的网站(www.bitumephotofest.it)的根目录重定向到子域名(2016.bitumephotofest.it)(我正在运行Wordpress多站点)。有用。

但我有另一个子域名(2015.bitumephotofest.it),它也会重定向到2016.bitumephotofest.it。

我希望重定向仅在www.bitumephotofest.it和2016.bitumephotofest.it之间起作用。 2015.bitumephotofest.it应该是独立的,因为它是一个不同的网站。

我试图通过类似情况的人来寻找问题,但总会有不同的东西,无论如何,这些解决方案对我不起作用。

这是我的代码:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteEngine On
RewriteBase / 
RewriteCond %{HTTP_HOST} 2016.bitumephotofest.it
RewriteCond %{REQUEST_URI} !wordpress/
RewriteRule ^(.*)$ /wordpress/$1 [L]

RewriteRule ^wp-admin$ wp-admin/ [R=301,L]

RewriteRule !^(2016) http://2016.bitumephotofest.it [L,R]

有谁知道我错过了什么? 提前谢谢!

1 个答案:

答案 0 :(得分:1)

如果您希望域2015.bitumephotofest.it保持不变,您可以使用

退出重写规则链
RewriteCond %{HTTP_HOST} ^2015\.bitumephotofest\.it$
RewriteRule ^ - [L]

-因为目标意味着不会重写,请参阅RewriteRule

  

- (破折号)
  短划线表示不应执行替换(现有路径未经过触摸传递)。当需要在不改变路径的情况下应用标志(见下文)时使用。