【问题标题】:prevent .htaccess affecting subfolder防止 .htaccess 影响子文件夹
【发布时间】:2023-03-08 10:45:01
【问题描述】:

我有以下主机设置:

/hostingroot/
 -/maindomainfiles/
 -/_sites/
  --/site1/
  --/site2/
  --/site3/
  --/site4/

主域“拥有”主机。我通过同一家公司购买了多个其他域,指向带有/_sites/ 的文件夹。

如果我在/hostingroot/ 文件夹内的.htaccess 中创建规则,例如RedirectMatch 301 ^/([0-9]{4})/([^/]+)/$ http://maindomain.co.uk/$2,它会影响对http://domain2.com/2011/pagetitle 的请求,而不仅仅是我预期的http://maindomain.com/2011/pagetitle

我尝试过使用:

RewriteCond %{REQUEST_URI} "/_sites/"
RewriteRule (.*) $1 [L]

但这没有用。

任何想法将不胜感激!

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    尝试删除 RedirectMatch 并继续:

    RewriteCond %{HTTP_HOST} ^(www\.)?maindomain.com$
    RewriteRule ^([0-9]{4})/([^/]+)/$ http://maindomain.co.uk/$2 [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-25
      • 2017-03-10
      • 2011-03-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多