简体   繁体   中英

How can I use PERIOD in the htaccess link?

I've tried to create a link like this: website.com/profile/name
website.com/profile.php?name=Name website.com/profile.php?name=名称
Everything works fine, except when I use a name with a dot in it. So for example: website.com/profile/Alex. This wouldn't work, and would just remove the dot from the link. So basically it wouldn't display that DOT in php.

This is my htaccess code.

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

([^/.]+) means any chars except . and / so this does not match alex. . If you want your rule to accept . in uri, change your rule's pattern to the following :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM