有人可以帮我从www.website.com/script/?id=3重写网址ID到www.website.com/script/3/
这意味着要删除id =?id。
这是我的.htaccess文件代码:
RewriteEngine on
RewriteRule ^script/([^/\.]+)/?$ script.php?id=$1 [L]
RewriteEngine on
RewriteRule ^script/(.*)$ script.php?id=$1 [L]
您需要重新排序规则,将特定的重写置于顶部。用以下内容替换您的htaccess内容:
RewriteEngine on
#rewrite /script/foobar to /script.php?id=foobar
RewriteRule ^script/([^/\.]+)/?$ script.php?id=$1 [L]
#remove .php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)/?$ /$1.php [L]