2015-12-15 179 views
1

我有这个网址:127.0.0.1/test.php?name=john.smith即成为127.0.0.1/profile/john.smith这个规则:重写规则的友好URL名称

RewriteRule ^profile/([^*]+)$ test.php?name=$1 [L] 

我想什么是删除/资料/简单地有127.0.0.1/john.smith

我遇到了一些问题,找到正确的重写规则。

感谢您的帮助。

回答

1

试试这个规则:

# If the request is not for a valid directory 
RewriteCond %{REQUEST_FILENAME} !-d 
# If the request is not for a valid file 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^/]+)/?$ test.php?name=$1 [L,QSA] 
+1

Woaw,令我印象深刻。这工作得很好。十分感谢你。 – Weebee