Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/261.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.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 使用htaccess动态设置URL格式_Php_.htaccess - Fatal编程技术网

Php 使用htaccess动态设置URL格式

Php 使用htaccess动态设置URL格式,php,.htaccess,Php,.htaccess,我有像这样的URL的用户配置文件页面 http://xxxxx.com/trainer-profile.php?id=MTAy&mrkr=LnBuZw== 我想更改URL格式,如 http://xxxxxxx.com/trainer-profile/John-Michael/ 已经更新了htacess代码,并从URL中删除了.php扩展名 但我需要像这样的url格式 http://xxxxxxx.com/trainer-profile/John-Michael/ http://xx

我有像这样的URL的用户配置文件页面

http://xxxxx.com/trainer-profile.php?id=MTAy&mrkr=LnBuZw==
我想更改URL格式,如

http://xxxxxxx.com/trainer-profile/John-Michael/
已经更新了htacess代码,并从URL中删除了.php扩展名

但我需要像这样的url格式

http://xxxxxxx.com/trainer-profile/John-Michael/ 
http://xxxxxxx.com/trainer-profile/Will-Smith/
http://xxxxxxx.com/trainer-profile/Michael/
用户正在动态添加,现在我已经注册了100多个用户。在stackoverflow中搜索并找到以下代码

RewriteEngine On
RewriteRule ^(bill/.+)$ /shop/$1 [L,NC]
RewriteRule ^shop/bill/?$ /shop/bill/home.php [L,NC]
可以像上面那样动态地格式化url吗

提前感谢。

您可以使用:

RewriteEngine On
RewriteRule ^trainer-profile/([^/]+?)/?$ /trainer-profile.php?id=$1 [L,NC]
但id将是链接中使用的名称

与:

重定向:

http://xxxxxxx.com/trainer-profile.php?id=John-Michael

您必须更改PHP页面中使用的ID代码培训师配置文件。PHP页面不显示,或出现错误?培训师配置文件页面显示,但无法获取ID。因此没有用户显示的详细信息如我在回答中所说,ID是链接名,在您的第一个链接中显示其他类型的ID,无法使用此url ID,如果它不在链接中。。。
http://xxxxxxx.com/trainer-profile.php?id=John-Michael