重写url问题
我希望有人能帮助我。对于我的网站,我有一个相应的移动网站,其内容与我的完整网站相同,但会在移动设备上显示。基本上我想将所有请求从完整站点发送到移动站点,除非 url 变量 sms 存在
所以在我的完整站点的 htaccess 文件中我有这个:
RewriteCond %{QUERY_STRING} !sms=1 [NC]
RewriteRule ^(.*) http://mobile.mysite.co.uk/$1 [QSA,NC]
但是当我到达 www.mysite.co.uk/news/index 时.cfm&sms 我在整个站点上收到以下 ColdFusion 错误:
File not found: /news/index.cfm
打开调试后,我注意到 CGI 变量 PATH_TRANSLATED 已从 更改为
C:\webistes\mysite\news\index.cfm
我
C:\JRun4\bin\http:\mobile.mysite.co.uk\news\index.cfm
不知道发生了什么?任何帮助或见解将不胜感激。
此外,我正在运行 ColdFusion 8 的多服务器安装,并使用为 ColdFusion 配置的 Apache。
I'm hoping someone can help me. For my website I have a corresponding mobile site that has the same content as my full site but display it for mobile devices. Basically I want to send all requests from the full site to the mobile site unless the url variable sms exists
So in my htaccess file for my full site I have this:
RewriteCond %{QUERY_STRING} !sms=1 [NC]
RewriteRule ^(.*) http://mobile.mysite.co.uk/$1 [QSA,NC]
But when I got to www.mysite.co.uk/news/index.cfm&sms I get the following ColdFusion error for the full site:
File not found: /news/index.cfm
With debugging turned on I've noticed that the CGI variable PATH_TRANSLATED has been changed from
C:\webistes\mysite\news\index.cfm
To
C:\JRun4\bin\http:\mobile.mysite.co.uk\news\index.cfm
I'm at a loss to undestand what's going on? Any help or insight would be greatly appreciated.
Additionally I'm running a multi server install of ColdFusion 8 and using Apache configured for ColdFusion.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您似乎想要进行外部重定向,但您的
RewriteRule
目前仅在内部重写 URL。尝试将R
和L
标志添加到您的规则中,看看是否会产生影响:我还添加了
RewriteCond
以确保它如果您已经在移动网站上,并且您的两个网站都指向同一个位置,则不会重定向您(如果没有,您可以将其删除;只是想在万一出现以下情况时为您省去麻烦)他们做到了)。It seems like you want to make an external redirection, but your
RewriteRule
currently only rewrites the URL internally. Try adding theR
andL
flags to your rule to see if that makes a difference:I also added in a
RewriteCond
to make sure that it doesn't redirect you if you're already on the mobile site, in the event that both of your sites point to the same place (you can remove it if they don't; just wanted to save you the headache in the event that they did).