用.htaccess修改url中的index.php


Change index.php in urls with .htaccess

我想替换url中的index.php

我的url示例:

http://example.com/index.php/blog/foo

i need be:

http://example.com/my.php/blog/foo
or
http://example.com/name/blog/foo
http://example.com/shop/blog/foo
...

您可以在DOCUMENT_ROOT/.htaccess文件中使用以下代码:

RewriteEngine On
RewriteBase /
RewriteRule ^[^/]+/(blog/.+)$ index.php/$1 [L,NC]

尝试使用sed

echo "http://example.com/index.php/blog/foo" | sed 's/index.php/my.php/'