【问题标题】:Get Originally Requested URL for "View Full Site" Link After Mobile Redirect移动重定向后获取“查看完整站点”链接的原始请求 URL
【发布时间】:2012-08-20 14:03:04
【问题描述】:

我已经彻底搜索了一个类似的主题,但找不到一个。在此希望有人能提供帮助。

=> 设置:

我正在使用我在野外发现的 .htaccess 移动重定向。

重定向将移动设备上的访问者从 www.MYSITE.com 发送到 m.MYSITE.com(一个简单的 .html“启动页面”)。在此移动版本上,访问者可以使用链接继续访问完整网站:

<a href="http://www.MYSITE.com">Visit Full Version</a>

=> 问题:

用户从搜索引擎访问 www.MYSITE.com/page。用户被重定向到 m.MYSITE.com 的移动启动页面,然后他们单击“访问完整版”链接。它们不会被重定向到 www.MYSITE.com/page 的完整站点版本,而是被发送到 www.MYSITE.com。

我需要访问者能够从 m.MYSITE.com 初始页面“查看完整”返回到最初请求的 URL(例如 www.MYSITE.com/page 甚至 www.MYSITE.com/page/post)版本”链接。

我的 .htaccess 代码如下:

# If you're not already on m.YOUR_DOMAIN_NAME.com,
# and if you're on a mobile device,
# and if you just got here (didn't get here by clicking links on YOUR_DOMAIN_NAME.com),
# and if you're not just looking for pictures
# then go to the mobile site instead
RewriteCond %{HTTP_HOST} !^m\.MYSITE\.com [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|webos|googlebot-mobile" [NC]
RewriteCond %{REQUEST_URI} !\.(jpg|png|gif)$ [NC]
RewriteCond %{HTTP_REFERER} !^http://(.*).MYSITE.com/.*$ [NC]
RewriteRule ^(.*)$ http://m.MYSITE.com [L,R=302]

=> 问题:

我可以在我的 .htaccess 文件和/或移动 index.php 中进行哪些操作,以将访问者作为“访问完整版”链接返回到他们最初请求的 URL?

非常感谢任何帮助!

谢谢, 布赖恩

【问题讨论】:

    标签: .htaccess redirect mobile


    【解决方案1】:

    在此处使用conditional .htaccess。

    通过parameter 决定是否要查看完整站点

    <a href="http://www.MYSITE.com?seeFullSite=YES">Visit Full Version</a>
    

    如果.htaccess 检查seeFullSite 参数是否为set 并且值是否为YES。如果为真,则不要重定向到您的移动网站。

    条件 .htaccess 示例 ::

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-06
      • 2012-08-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多