【问题标题】:Root redirects to just one subdomain in .htaccess根重定向到 .htaccess 中的一个子域
【发布时间】:2016-11-01 11:38:21
【问题描述】:

我希望我的网站 (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]

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

【问题讨论】:

    标签: .htaccess redirect subdomain multisite


    【解决方案1】:

    如果您希望域2015.bitumephotofest.it 保持不变,您可以退出重写规则链

    RewriteCond %{HTTP_HOST} ^2015\.bitumephotofest\.it$
    RewriteRule ^ - [L]
    

    -作为目标意味着不重写,见RewriteRule

    -(破折号)
    破折号表示不应执行替换(现有路径通过未触及)。当需要在不更改路径的情况下应用标志(见下文)时使用此选项。

    【讨论】:

      猜你喜欢
      • 2012-11-18
      • 1970-01-01
      • 2014-06-24
      • 2017-06-26
      • 1970-01-01
      • 2012-02-22
      • 2012-07-25
      • 2011-09-25
      • 2016-03-26
      相关资源
      最近更新 更多