htaccess 动态用户名
您好,我正在使用此代码作为我的子目录重定向用户名
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ profile.php?username=$1&%{QUERY_STRING}
我遇到这个问题,即用户输入domain.com/username/ 将会出现问题,只有当他们输入domain.com/username 时它才有效 有
任何解决方案吗?
另外,例如,如果我有一个真实的目录调用/images/,当它们进入domain.com/images时。关于某些循环问题将会出现错误。解决这个问题的方法是什么?
Hi i'm using this code for my subdirectories redirect for usernames
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ profile.php?username=$1&%{QUERY_STRING}
I have this problem that is user enter domain.com/username/ it will have problems, it only works if they enter domain.com/username
Any solutions to this??
Also, example if i have a real directory call /images/, when they enter domain.com/images. there will be an error regarding some looping problem. what is the way to solve this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最好让您的重写需要尾部斜杠。
将非斜线结尾的网址重定向到斜线结尾的网址
然后您可以使用类似以下内容
:我希望这会有所帮助。
It's better to make your rewrites require the trailing slash.
then you can redirect non-slash ended urls to slash ended one,
using something like this :
I hope this helps.