Php 重写友好url名称的规则
我有一个url:127.0.0.1/test.php?name=john.smith根据以下规则变成127.0.0.1/profile/john.smith:Php 重写友好url名称的规则,php,apache,.htaccess,mod-rewrite,url-rewriting,Php,Apache,.htaccess,Mod Rewrite,Url Rewriting,我有一个url:127.0.0.1/test.php?name=john.smith根据以下规则变成127.0.0.1/profile/john.smith: RewriteRule ^profile/([^*]+)$ test.php?name=$1 [L] # If the request is not for a valid directory RewriteCond %{REQUEST_FILENAME} !-d # If the request is not for a valid
RewriteRule ^profile/([^*]+)$ test.php?name=$1 [L]
# 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]
我希望的是删除/配置文件/只是拥有127.0.0.1/john.smith
为了找到正确的规则,我遇到了一些问题
谢谢你的帮助。试试这个规则:
RewriteRule ^profile/([^*]+)$ test.php?name=$1 [L]
# 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]
哇,我印象深刻。这非常有效。非常感谢。