当前网址:
http://localhost/blog/profile.php?username=Username&page_type=following
我希望它是:
http://localhost/blog/profile/Username/following
当前.htaccess:
RewriteEngine On
CheckCaseOnly On
CheckSpelling On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^profile/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L]
有可能以这种方式重写吗?或者有更好的方法吗?
答案 0 :(得分:0)
您需要两个捕获组:
RewriteRule ^profile/(.*?)/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L]
答案 1 :(得分:0)
RewriteRule
模式中的$2
没有page_type
RewriteRule ^profile/(.*?)/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L]