RewriteEngine On
Options +FollowSymLinks
RewriteBase /
RewriteRule ^api/people/([^/]*)$ api/people.php?id=$1
RewriteRule ^api/people/([^/]*)/([^/]*)$ api/people.php?action=$1&id=$2
在上面的示例中,有RewriteRules
个人检测到网址是否为domain.com/api/people/1
而另一个检测到domain.com/api/people/settings/1
当我尝试访问后一个url时,我通常会得到Error 500,有没有办法整理HTACCESS以便它可以检测到url是第一个还是最后一个?
答案 0 :(得分:0)
保持你的.htaccess像这样:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^api/people/([^/]+)/?$ api/people.php?id=$1 [L,QSA]
RewriteRule ^api/people/([^/]+)/([^/]+)/?$ api/people.php?action=$1&id=$2 [L,QSA]