0

大家好,
我需要将 http://mysite.com/user/profile/following?profile_name=MYNAME重写 为http://mysite.com/user/profile/MYNAME/following

我写了这样的规则:

RewriteRule user/profile/(.*)/(.*) /user/profile/$2?profile_name=$1 [L,R=301]  

当我在浏览器中输入http://mysite.com/user/profile/MYNAME/following之类的网址 时,它总是将我重定向到http://mysite.com/user/profile/following?profile_name=MYNAME

我错过了什么?

提前致谢

4

1 回答 1

0

您可以使用以下代码:

# external redirect from actual URL to pretty one
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+user/profile/([^?]+)\?profile_name=([^\s&]+) [NC]
RewriteRule ^ /user/profile/%1/%2? [R=301,L]

# internal forward from pretty URL to actual one
RewriteRule ^user/profile/([^/]+)/([^/]*)/?$ /user/profile/$2?profile_name=$1 [L,NC,QSA]  
于 2013-10-24T06:49:07.290 回答