htaccess移动重定向特定的网址 [英] htaccess mobile redirect for specific url

查看:76
本文介绍了htaccess移动重定向特定的网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个具有移动友好内容的重复m.website.com。但是仍然有一些桌面页面我没有为它创建移动版本,我不希望将它们重定向到移动设备。

是否有一个htaccess代码,它允许我根据其设备的用户代理将页面重定向到移动网站上的相同网址,那没有创建的移动版本停留在桌面版本中?我也希望他们能够选择他们是否想回到桌面版本,如果他们想要回到桌面版的链接。



www.website.com/page1.htm到m.website.com/page1.htm和www.website.com/page2.htm停留在桌面版本中,如果没有移动版本的话。



感谢您的帮助。 / p>

  RewriteEngine On 

RewriteCond%{HTTP_ACCEPT}text \ / vnd\.wap\ .wml | application \ / vnd\.wap\.xhtml\ + xml[NC,OR]
RewriteCond%{HTTP_USER_AGENT}sony | symbian | nokia | samsung | mobile | windows ce | epoc | opera[NC,OR]
RewriteCond%{HTTP_USER_AGENT}mini | nitro | j2me | midp- | cldc- | netfront | mot | up \.browser | up \.link | audiovox[NC ,或]
RewriteCond%{HTTP_USER_AGENT}blackberry | ericsson,| panasonic | philips | sanyo | sharp | sie - [NC,OR]
RewriteCond%{HTTP_USER_AGENT}portalmmm | blazer | avantgo |危险| palm | series60 | palmsource | pocketpc[NC,OR]
RewriteCond%{HTTP_USER_AGENT}智能手机|流动站| ipaq | au-mic,| alcatel | ericy | vodafone \ / | wap1\。 wap2 \。| iPhone | android[NC]
RewriteRule ^ page1\.htm $ http://m.website.com% {REQUEST_URI} [L,R = 302,NC]


I have a created a duplicate m.website.com that have mobile friendly contents in them. However there are still some desktop page that I did not create a mobile version for it and I don't wish to redirect them to the mobile.

Is there a htaccess code which allows me to redirect just the pages that I wanted to the same url on the mobile site based on the user agent of their device and yet pages that does not have the mobile version created stays in the desktop version? I also want them to be able to choose if they want to go back to the desktop version if they want it to with the links that go back to the desktop page.

www.website.com/page1.htm to m.website.com/page1.htm and www.website.com/page2.htm stay in desktop version if there no mobile version of it.

Thanks for all the help.

解决方案

Try this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTP_ACCEPT} "text\/vnd\.wap\.wml|application\/vnd\.wap\.xhtml\+xml" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "sony|symbian|nokia|samsung|mobile|windows ce|epoc|opera" [NC,OR]
RewriteCond %{HTTP_USER_AGENT} "mini|nitro|j2me|midp-|cldc-|netfront|mot|up\.browser|up\.link|audiovox"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "blackberry|ericsson,|panasonic|philips|sanyo|sharp|sie-"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "portalmmm|blazer|avantgo|danger|palm|series60|palmsource|pocketpc"[NC,OR]
RewriteCond %{HTTP_USER_AGENT} "smartphone|rover|ipaq|au-mic,|alcatel|ericy|vodafone\/|wap1\.|wap2\.|iPhone|android"[NC]
RewriteRule ^page1\.htm$ http://m.website.com%{REQUEST_URI} [L,R=302,NC]

这篇关于htaccess移动重定向特定的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆