【问题标题】:Link from mobile site after htaccess redirect to desktop versionhtaccess 重定向到桌面版本后从移动网站链接
【发布时间】:2012-01-19 06:39:01
【问题描述】:

我有一个移动版网站http://www.m.fdl.de/ 和桌面版http://www.fdl.de/

通过.htaccess 重定向,我将所有移动用户链接到移动版本,运行良好。

在我的移动网站上,我在页脚中设置了一个链接,该链接应链接回桌面版本。 我尝试了几个在 stackoverflow 上找到的 .htaccess 解决方案,但没有成功。

我的链接总是将我链接回移动网站。

这是我的.htaccess。我在这篇文章中找到了它:Mobile Redirect using htaccess

RewriteEngine on
RewriteBase /
# Check if this is the noredirect query string
RewriteCond %{QUERY_STRING} (^|&)m=0(&|$)
# Set a cookie, and skip the next rule
RewriteRule ^ - [CO=mredir:0:www.fdl.de]

# Check if this looks like a mobile device
# (You could add another [OR] to the second one and add in what you
#  had to check, but I believe most mobile devices should send at
#  least one of these headers)
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP:Profile}       !^$ [OR]
RewriteCond %{HTTP_USER_AGENT}      "acs|alav|alca|amoi|audi|aste|avan|benq|bird|blac|blaz|brew|cell|cldc|cmd-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "dang|doco|eric|hipt|inno|ipaq|java|jigs|kddi|keji|leno|lg-c|lg-d|lg-g|lge-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT}  "maui|maxo|midp|mits|mmef|mobi|mot-|moto|mwbp|nec-|newt|noki|opwv" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "palm|pana|pant|pdxg|phil|play|pluc|port|prox|qtek|qwap|sage|sams|sany" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sch-|sec-|send|seri|sgh-|shar|sie-|siem|smal|smar|sony|sph-|symb|t-mo" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "teli|tim-|tosh|tsm-|upg1|upsi|vk-v|voda|w3cs|wap-|wapa|wapi" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "wapp|wapr|webc|winw|winw|xda|xda-" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "up.browser|up.link|windowssce|iemobile|mini|mmp" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "symbian|midp|wap|phone|pocket|mobile|pda|psp" [NC]
RewriteCond %{HTTP_USER_AGENT} !macintosh [NC]

# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST}          !^m\.
# Can not read and write cookie in same request, must duplicate condition
RewriteCond %{QUERY_STRING} !(^|&)m=0(&|$) 

# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE}        !^.*mredir=0.*$ [NC]

# Now redirect to the mobile site
RewriteRule ^ http://m.fdl.de [R,L]

如果有人能帮助我,那就太好了!

【问题讨论】:

  • 开始时您复制的脚本似乎已损坏。
  • 尝试将 cookie 的域设置为 .fdl.de 并将 RewriteCond %{HTTP_COOKIE} !^.*mredir=0.*$ [NC] 更改为 RewriteCond %{HTTP_COOKIE} !^.*?mredir=0.*$ [NC](使第一个包罗万象变得懒惰)。这是我能发现的仅有的两个潜在问题。
  • @Gerben :你所说的“破碎”是什么意思?它会将我发送到移动页面。到目前为止,一切都很好。返回桌面站点的链接无效。没错。
  • @dambrisco:感谢您的帮助。我试过你的建议,但没有成功。 :(

标签: .htaccess mobile redirect


【解决方案1】:

我可能真的迟到了,但我发现完整网站的链接必须是这样的:

<a href="http://www.example.com?m=0">Full Site</a>

希望对您有所帮助。

【讨论】:

  • 这与问题中发布的 .htaccess 有何关系?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-04
  • 2013-06-04
相关资源
最近更新 更多