我应该编写What.htaccess代码来转换
localhost/article.php?id=something&number=something
进入
localhost/article/id
思想家伙?
答案 0 :(得分:1)
您可以在DOCUMENT_ROOT/.htaccess
文件中使用这样的规则:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+article\.php\?id=([^\s&]+) [NC]
RewriteRule ^ article/%1? [R=302,L]
# internal forward from pretty URL to actual one
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^article/([^/]+)/?$ article.php?id=$1 [L,QSA,NC]