mobile site redirect to desktop version using .htaccess

后端 未结 3 1607
野的像风
野的像风 2020-12-12 00:42

I have a mobile site and it has just started a service for desktop users also. How do I use .htaccess to redirect users using the desktop to the desktop version of the site?

3条回答
  •  误落风尘
    2020-12-12 01:05

    I think the code below is target more accuracy at the desktop browsers. You can remove the 1st USER_AGENT line if you don't want to exclude IE 10 on touch based devices.

    RewriteCond %{REQUEST_URI} !^/desktop/.*$
    RewriteCond %{HTTP_USER_AGENT} !Windows\ NT.+Touch [NC]
    RewriteCond %{HTTP_USER_AGENT} Windows\ NT\ 6|Macintosh|Ubuntu|Linux\ (x86_64|i686)|CrOS [NC]
    RewriteRule ^(.*)$ /desktop/ [L,R]
    

    All desktop browsers which are using Windows, Mac, Linux will be redirect to /desktop/.

提交回复
热议问题