我已经下载了phpDolphon社交网络脚本。它很棒,但它没有干净的URL。有人知道怎么做吗?
以下是索引页面的示例:
mydomain.com/index.php?a=feed
我希望将其更改为:
mydomain.com/
以下是个人资料页面的示例:
mydomain.com/index.php?a=profile&u=daniel
我希望将其更改为:
mydomain.com/user/daniel
我试过这个,但它似乎不起作用。有什么想法吗?
RewriteEngine On
RewriteRule ^([A-Za-z0-9-+_%*?]+)/([A-Za-z0-9-+_%*?]+)/?$ index.php?a=$1&u=$2 [L]
答案 0 :(得分:0)
怎么样:
RewriteEngine On
RewriteCond %{THE_REQUEST} \ /+index\.php\?a=feed
RewriteRule ^ /? [L,R=301]
RewriteCond %{THE_REQUEST} \ /+index\.php\?a=profile&u=([^&\ ]+)
RewriteRule ^ /user/%1? [L,R=301]
RewriteRule ^user/([^/]+)$ /index.php?a=profile&u=$1 [L,QSA]
RewriteRule ^$ /index.php?a=feed [L,QSA]
答案 1 :(得分:0)
您需要非常具体的规则:
# no 'feeds' in alias
RewriteRule ^$ index.php?a=feed (maybe it needs a /)
# 'user' in one, 'profile' in other
RewriteRule ^user/(\w\d+)$ index.php?a=profile&u=$1
etc