我不能完全弄清楚如何在我的.htaccess文件中使用正则expression式来从URL的末尾移除index.php,当且仅当它是string中的最后一个东西。
如果url是example.com/path/index.php,它应该变成:example.com/path/
但是如果url是example.com/path/index.php?blah=0,它应该保持不变。
任何帮助吗? 我认为这可能会起作用,但似乎并不能保留上述后一种情况:
RewriteRule ^(。*)$ /index.php/$1 [L]
使用
RewriteCond %{QUERY_STRING} ^$ RewriteRule ^(.*/)index.php$ $1 [L]