简体   繁体   中英

Change index.php in urls with .htaccess

I want replace index.php in urls

my url example:

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

i need to be:

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

You can use this code in your DOCUMENT_ROOT/.htaccess file:

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/'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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