简体   繁体   English

如何使用URL重写从URI中剥离index.php?

[英]How can I use URL rewriting to strip index.php from a URI?

Here's what I need- 这就是我需要的 -

  1. RegEx to match a url pattern and rewrite it to something else RegEx匹配url模式并将其重写为其他内容
  2. 301 redirect old pattern to new pattern 301将旧模式重定向到新模式

Here's what I have- 这是我的 -

I have a url pattern that currently looks like this-- 我有一个网址模式,目前看起来像这样 -

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

I want to create a pattern match on the url " http://www.foo.com/press/index.php/ " and rewrite to remove the "/index.php" and the new url would be-- 我想在网址“ http://www.foo.com/press/index.php/ ”上创建一个模式匹配,并重写以删除“/index.php”,新的网址将是 -

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

But I want that as a pattern match on the redirect and rewrite so other urls will also be stripped of the "/index.php" which will always fall after the http://www.foo.com/press/ 但是我希望它作为重定向和重写的模式匹配,所以其他网址也将被剥夺“/index.php”,它将始终落在http://www.foo.com/press/之后

Thanks for your help in advance! 感谢您的帮助!

RewriteRule ^press/index.php/(.*) /press/$1 [R=301]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM