2016-11-04 83 views
0

我试图创建这样一个链接:website.com/profile/name
来自: website.com/profile.php?name=Name
一切正常,只是当我使用一个名称在它的一个点。例如:website.com/profile/Alex。 这不起作用,只会从链接中删除点。所以基本上它不会在PHP中显示DOT。如何在htaccess链接中使用PERIOD?

这是我的htaccess代码。

RewriteEngine On 

ErrorDocument 404 /alliance/404.php 

RewriteCond %{ENV:REDIRECT_STATUS} ^$ 
RewriteRule ^([^/.]+)\.php - [F,L,R=404] 

RewriteRule ^([^/.]+)$ $1.php [L] 

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

回答

0

([^/.]+)意味着除了./任何字符所以这种不匹配alex.。如果您希望规则在uri中接受.,请将规则的模式更改为以下内容:

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

感谢您的评论。但可悲的是,它不起作用。 –