Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 重写友好url名称的规则_Php_Apache_.htaccess_Mod Rewrite_Url Rewriting - Fatal编程技术网

Php 重写友好url名称的规则

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

我有一个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 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]

哇,我印象深刻。这非常有效。非常感谢。