【问题标题】:.htaccess Change root directory with exceptions for a list of directories.htaccess 更改根目录,但目录列表除外
【发布时间】:2021-01-29 19:22:49
【问题描述】:

嗨,
我的 .htaccess 代码将根目录从 public_html 更改为新站点文件夹,并且运行良好。

重写引擎开启 RewriteCond %{HTTP_HOST} ^example.com.au$ [NC,OR] RewriteCond %{HTTP_HOST} ^www.example.com.au$ RewriteCond %{REQUEST_URI} !new-site/ 重写规则 (.*) /new-site/$1 [L]

它的问题是:我想保留一些从默认目录加载的旧网站的内页。

https://example.com.au/load-this-from-the-old-site/
https://example.com.au/load-this-from-the-old-site/another-page/
https://example.com.au/etc/

以上页面不是目录而是从旧的public_html/index.php文件中请求的页面

如有任何帮助,将不胜感激

【问题讨论】:

    标签: .htaccess


    【解决方案1】:

    在您的规则中插入排除条件,如下所示:

    RewriteEngine on
    
    RewriteCond %{HTTP_HOST} ^(?:www\.)?example\.com\.au$ [NC]
    RewriteCond %{REQUEST_URI} !^/(new-site|load-this-from-the-old-site|etc)/ [NC]
    RewriteRule (.*) new-site/$1 [L]
    

    【讨论】:

      猜你喜欢
      • 2011-08-24
      • 2018-08-09
      • 2012-01-11
      • 1970-01-01
      • 1970-01-01
      • 2012-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多