0

当前网址:

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]

可以这样重写吗?还是有更好的方法?

4

2 回答 2

0

您需要两个捕获组:

RewriteRule ^profile/(.*?)/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L]
于 2013-04-08T20:58:47.487 回答
0

你没有$2for page_typetheRewriteRule模式

RewriteRule ^profile/(.*?)/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L]
于 2013-04-08T20:59:00.203 回答