2013-04-08 35 views
0

當前網址:mod_rewrite的URL

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

需要兩個拍攝組:

RewriteRule ^profile/(.*?)/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L] 
0

您不必爲page_type一個$2RewriteRule模式

RewriteRule ^profile/(.*?)/(.*)$ /blog/profile.php?username=$1&page_type=$2 [QSA,L]