【问题标题】:Redirecting /directory/index.html to /directory/将 /directory/index.html 重定向到 /directory/
【发布时间】:2012-01-26 09:41:55
【问题描述】:

嘿,伙计们,我不知道如何措辞才能获得正确的搜索,所以这里是 我想将 /directory/index.html 的所有查询重定向到 /directory/ 这是(真的)/directory/index.php 我写了这个,但它插入了我的整个 网络根结构(/var/www/html/directory/index.php)所以这是不行的,也许 有人可以帮我一点吗?这有意义吗?

这是代码

重写引擎开启

重写规则 ^index.(htm|html?)$ ^index.php [R=301,L]

编辑

我用这个解决了,但我确定有更好的方法吗?

重写引擎开启

重写规则 ^index.(htm|html?)$ %{REQUEST_URI}/../index.php [R=301,L]

【问题讨论】:

    标签: mod-rewrite redirect apache


    【解决方案1】:

    这可能有效(而且我认为更干净):

    RewriteEngine On
    RewriteRule ^index\.(htm|html?)$ /index.php [QSA,NC,R=301,L]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-29
      • 1970-01-01
      • 1970-01-01
      • 2019-12-21
      • 2019-03-03
      • 2015-04-10
      • 1970-01-01
      • 2015-05-06
      相关资源
      最近更新 更多