简体   繁体   English

如何通过移动PHP页面加载网页桌面版(用户代理设置?)

[英]How to load Desktop version of webpage through mobile PHP page (user agent settings?)

I have a PHP page (which is displayed through a mobile/android browser) - however, when accessing a link to an external site - it automatically redirects to the mobile version. 我有一个PHP页面(通过移动/ Android浏览器显示),但是,当访问到外部站点的链接时,它将自动重定向到移动版本。

I want the link to take user to the desktop version of the webpage even when accessed through a mobile browser. 我希望即使通过移动浏览器进行访问,该链接也可以将用户带到网页的桌面版本。

Is there a way i can specify useragent/or any other setting in my PHP page code to acheive this? 有没有一种方法可以在我的PHP页面代码中指定useragent /或任何其他设置来实现这一目标? Thanks. 谢谢。

Spoofing the user agent string will be a challenge, as it requires you to control the behavior of the browser. 欺骗用户代理字符串将是一个挑战,因为它需要您控制浏览器的行为。 You might be able to do it with JavaScript or something, but I doubt it. 您可能可以使用JavaScript或其他方式执行此操作,但我对此表示怀疑。

If it's just one site, you may wish to take a look at how they're handling redirection of mobile devices. 如果只是一个站点,您可能希望看看它们如何处理移动设备的重定向。 Often, sites will provide mechanisms for overriding the redirect script. 通常,站点将提供用于覆盖重定向脚本的机制。

For example, sites using the UC Mobile Web Framework (http://mwf.ucla.edu/) allows you to override their redirect script with a query string parameter. 例如,使用UC移动Web框架(http://mwf.ucla.edu/)的站点允许您使用查询字符串参数覆盖其重定向脚本。 The UCSF Library (http://library.ucsf.edu/) is using that framework for mobile redirects. UCSF库(http://library.ucsf.edu/)正在使用该框架进行移动重定向。 If you are on a mobile device and go to http://library.ucsf.edu/ then you will be redirected to the mobile version of the site. 如果您使用的是移动设备,请访问http://library.ucsf.edu/,然后您将被重定向到该网站的移动版本。 However, if you go to http://library.ucsf.edu/?ovrrdr=1 then you will get the desktop version. 但是,如果您访问http://library.ucsf.edu/?ovrrdr=1 ,则将获得桌面版本。

What you are describing, no. 您所描述的是,否。 You do not have control of an external site therefore you cannot control what is being served. 您无法控制外部站点,因此无法控制所提供的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM