【问题标题】:allow index.php only on subdomain仅在子域上允许 index.php
【发布时间】:2015-03-14 07:30:16
【问题描述】:

我在某个域上有一个网站。 以及子域上的另一个网站(指向一个文件夹)。

我在尝试访问子域上的网站时收到此错误:
strong text 禁止
您无权访问此服务器上的 /index.php。


ma​​in-website 的 htaccess 中,我看到此代码删除 index.php 以使 url 干净:

#### remove index.php ##########################
    RewriteCond %{THE_REQUEST} !^POST
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php(.*)\ HTTP/ [NC]
    RewriteRule ^index\.php(.*)$ http:\/\/www.mainsite.com/$1 [R=301,L]


但是在可以通过子域
访问的网站上 子文件夹中的数据,
. . .
我似乎需要 index.php(对吗?)

所以问题是: 我怎样才能允许 index.php 仅针对 子文件夹/子域的请求?

【问题讨论】:

    标签: .htaccess mod-rewrite subdomain


    【解决方案1】:

    您可以在规则中添加RewriteCond 以仅针对一个特定域:

    RewriteCond %{HTTP_HOST} ^(www\.)?mainsite\.com$ [NC]
    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.*)index\.php(.*)\ HTTP/ [NC]
    RewriteRule ^index\.php(.*)$ http://www.mainsite.com/$1 [R=301,L]
    

    【讨论】:

      猜你喜欢
      • 2018-11-08
      • 1970-01-01
      • 1970-01-01
      • 2018-01-09
      • 1970-01-01
      • 2011-11-15
      • 1970-01-01
      • 2023-03-27
      • 1970-01-01
      相关资源
      最近更新 更多