mod rewrite rule to include period

时光总嘲笑我的痴心妄想 提交于 2019-12-24 15:40:28

问题


What should I add the rewrite rule to include reading periods?

I have this currently on my .htaccess:

RewriteEngine on
RewriteRule ^([a-zA-Z0-9_-]+)$ /user/public/index.php?username=$1 [L]

if i have this it works fine:

http://mydomain.com/user/public/usernamehere

but if i have this i get the 404:

http://mydomain.com/user/public/usernametwo.net

Thanks.


回答1:


Add the point to your set of allowed input.

Try this...

<IfModule mod_rewrite.c>

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([a-zA-Z0-9\._-]+)$ /user/public/index.php?username=$1 [L]

</IfModule>

I don't know the URL structure of your page, but a better way of rewriting would be...

RewriteRule ^user/public/([a-zA-Z0-9\._-]+)$ /user/public/index.php?username=$1 [L]


来源:https://stackoverflow.com/questions/9621584/mod-rewrite-rule-to-include-period

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!