问题
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