如何在.htaccess中重写URL,这里有什么问题


How to rewrite URL in .htaccess, whats wrong here

认为用户输入

localhost/app/public/anything/anything/index/php/id/5
我想把它改成
localhost/app/public/index.php?id=5

我写的表达式是这样的

RewriteRule ^index/php/id/([0-9]+)$ http://localhost/saecms/public/index.php?id=$1 [L]

但是它不工作,这里有什么问题?谢谢你

您可以在/app/public/.htaccess文件中使用此规则:

RewriteEngine On
RewriteBase /app/public/
RewriteRule (?:^|/)index.php/id/('d+)/?$ index.php?id=$1 [L,QSA,NC]