【问题标题】:How can I use URL rewriting to strip index.php from a URI?如何使用 URL 重写从 URI 中去除 index.php?
【发布时间】:2009-04-09 14:23:54
【问题描述】:

这是我需要的-

  1. RegEx 匹配 url 模式并将其重写为其他内容
  2. 301 将旧模式重定向到新模式

这就是我所拥有的-

我有一个目前看起来像这样的 url 模式--

http://www.foo.com/press/index.php/2009/4-reasons-to-buy-now/

我想在 url“http://www.foo.com/press/index.php/”上创建一个模式匹配并重写以删除“/index.php”,新的 url 将是--

http://www.foo.com/press/2009/4-reasons-to-buy-now/

但我希望将其作为重定向和重写的模式匹配,因此其他网址也将被删除“/index.php”,这将总是落在http://www.foo.com/press/

提前感谢您的帮助!

【问题讨论】:

    标签: regex .htaccess mod-rewrite


    【解决方案1】:
    RewriteRule ^press/index.php/(.*) /press/$1 [R=301]
    

    【讨论】:

      猜你喜欢
      • 2013-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-04
      • 2012-05-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多