重写url问题

发布于 2024-09-07 19:35:41 字数 713 浏览 5 评论 0原文

我希望有人能帮助我。对于我的网站,我有一个相应的移动网站,其内容与我的完整网站相同,但会在移动设备上显示。基本上我想将所有请求从完整站点发送到移动站点,除非 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七度光 2024-09-14 19:35:41

您似乎想要进行外部重定向,但您的 RewriteRule 目前仅在内部重写 URL。尝试将 RL 标志添加到您的规则中,看看是否会产生影响:

# Stop and redirect immediately to the mobile site
RewriteCond %{QUERY_STRING}     !sms=1         [NC]
RewriteCond %{HTTP_HOST}        !^mobile
RewriteRule ^(.*)    http://mobile.mysite.co.uk/$1 [QSA,NC,R,L]

我还添加了 RewriteCond 以确保它如果您已经在移动网站上,并且您的两个网站都指向同一个位置,则不会重定向您(如果没有,您可以将其删除;只是想在万一出现以下情况时为您省去麻烦)他们做到了)。

It seems like you want to make an external redirection, but your RewriteRule currently only rewrites the URL internally. Try adding the R and L flags to your rule to see if that makes a difference:

# Stop and redirect immediately to the mobile site
RewriteCond %{QUERY_STRING}     !sms=1         [NC]
RewriteCond %{HTTP_HOST}        !^mobile
RewriteRule ^(.*)    http://mobile.mysite.co.uk/$1 [QSA,NC,R,L]

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文