子域的重写规则
我的 .htaccess 中的重写规则有问题 首先,我的网站上有一个 wlidcard (*.site.com)
这是我网站的路径:
/home/www/static/
/home/www/home/
/home/www/.htaccess
所以我在网站的根目录下创建了一个 .htaccess:
RewriteCond %{HTTP_HOST} static.site.com [NC]
RewriteRule !^static/ static%{REQUEST_URI}
RewriteCond %{HTTP_HOST} www.site.com [NC]
RewriteRule !^home/ home%{REQUEST_URI}
这些重定向运行得很好,但是当我想去时例如:
http://www.site.com/img
有一个问题,它在 http://www.site.com/home/img/
中重定向我,
但是当我输入 http://www.site.com/ 时图片/
最后的反斜杠一切都好。
感谢您的回复:)
I have a problem with my rewriterule in my .htaccess
To begin, i have a wlidcard on my website (*.site.com)
Here is the path of my website :
/home/www/static/
/home/www/home/
/home/www/.htaccess
So i made a .htaccess at the root of my website with :
RewriteCond %{HTTP_HOST} static.site.com [NC]
RewriteRule !^static/ static%{REQUEST_URI}
RewriteCond %{HTTP_HOST} www.site.com [NC]
RewriteRule !^home/ home%{REQUEST_URI}
These redirects run pretty good but when i want to go to for example :
http://www.site.com/img
There's a problem, it's redirecting me in http://www.site.com/home/img/
But when i type http://www.site.com/img/
with the final backslash everything is ok.
Thanks for replies :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试:
如果斜杠缺失,这应该会为您添加缺失的斜杠。您需要包含“L”标志来告诉重写引擎这是您的最后一次重写,而不是在此规则之上应用其他规则。
Try:
This should add on the missing slash for you if it's missing. You'd want to include the 'L' flag to tell the rewrite engine that this is your LAST rewrite and not to apply the other rule on top of this one.
不匹配映射到现有目录的请求
如果这不起作用,请尝试匹配请求加上另一个斜杠是否是目录?
Don't match requests which map to existing directories
If that doesn't work, try matching whether the request plus another slash is a directory?
已解决:
Solved :