我有一个.htaccess文件,我想像现在一样向资源页面添加更多参数。
现在我有:/resources/<id>
但我想:/resources/<id>/<name>
这是我目前的.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+resources(?:\.php)?\?id=([a-z,A-Z,0-9]+) [NC]
RewriteRule ^ resources/%1? [R,L]
RewriteRule ^resources/([a-z,A-Z,0-9]+)/?$ resources.php?id=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \s/+profile(?:\.php)?\?id=([a-z,A-Z,0-9]+) [NC]
RewriteRule ^ profile/%1? [R,L]
RewriteRule ^profile/([a-z,A-Z,0-9]+)/?$ profile.php?name=$1 [L,QSA]
RewriteCond %{THE_REQUEST} \s/+error(?:\.php)?\?id=([a-z,A-Z,0-9]+) [NC]
RewriteRule ^ error/%1? [R,L]
RewriteRule ^error/([a-z,A-Z,0-9]+)/?$ error.php?id=$1 [L,QSA]
RewriteCond %{REQUEST_FILENAME}\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php
ErrorDocument 400 /error/400
ErrorDocument 401 /error/401
ErrorDocument 403 /error/403
ErrorDocument 404 /error/404
ErrorDocument 500 /error/500
ErrorDocument 503 /error/503
Redirect /index.php /home
Redirect /index.html /home
RewriteRule /sitemap.xml /sitemap.xml.php
答案 0 :(得分:2)
这条规则:
RewriteRule ^resources/([a-z,A-Z,0-9]+)/?$ resources.php?id=$1 [L,QSA]
添加此规则:
RewriteRule ^resources/([a-z,A-Z,0-9]+)/([a-z,A-Z,0-9]+)/?$ resources.php?id=$1&name=$2 [L,QSA]