簡體   English   中英

用.htaccess更改URL中的index.php

[英]Change index.php in urls with .htaccess

我想替換網址中的index.php

我的網址示例:

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

我需要成為:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM