【问题标题】:htaccess redirect my entire site except 1 filehtaccess 重定向我的整个网站,除了 1 个文件
【发布时间】:2013-01-06 15:15:47
【问题描述】:

我正在尝试将我的整个网站(包括所有子目录)重定向到 www.mysite.com/index.html 文件。

我环顾四周,发现您使用 .htaccess 来执行此操作,并且只需要一些帮助来在调用 index.html 时停止重定向。

到目前为止,我的 .htaccess 文件如下所示:

RewriteEngine On

RewriteCond %{REQUEST_URI} !=/index.html
Redirect 301 / http://www.MySiteHere.com/index.html

所以上面所做的是将我网站上的所有内容重定向到我想要做的 index.html ,但它会继续请求 index.html 文件。因此,当请求 index.html 文件时,我需要一些帮助来阻止 .htaccess 文件运行。

有人有什么想法吗?

【问题讨论】:

    标签: .htaccess redirect


    【解决方案1】:

    您在这里混合了来自 2 个不同模块的指令。 RewriteCond 是 mod_rewrite 的一部分,它只应用于紧跟 RewriteRule 指令的下一个。 Redirect 指令是 mod_alias 的一部分,它被应用在 URL 文件映射管道中完全不同的位置。看起来你只想坚持使用 mod_rewrite:

    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/index.html$
    RewriteRule ^ http://www.MySiteHere.com/index.html [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多