我有 2 个网站,一个是常规的(用于台式机),另一个是为移动设备设计的。它们都有相同的内容,但移动网站是为手机设计的(iphone、黑莓等)
这是我正在寻找的:
当用户在移动设备上到达我的站点时,将自动重定向到移动版本。在移动版本上,我有一个链接,上面写着“查看完整的 html”,当他们单击该链接时,无论他们使用什么设备(桌面、iPhone 或其他设备),他们都会被发送到该网站的完整版本
使用 Litespeed 网络服务器。
我无法通过 HTACCESS 让它工作。这是我的 .htacess 的样子:
Options -Indexes
RewriteEngine On
RewriteBase /
#Added the rule below so that redirecting to the index.php does not operate on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR]
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php
# Check if mobile=1 is set and set cookie 'mobile' equal to 1
RewriteCond %{QUERY_STRING} (^|&)mobile=1(&|$)
RewriteRule ^ - [CO=mobile:1:%{HTTP_HOST},S]
# Check if mobile=0 is set and set cookie 'mobile' equal to 0
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [CO=mobile:0:%{HTTP_HOST},S]
# cookie can't be set and read in the same request so check
RewriteCond %{QUERY_STRING} (^|&)mobile=0(&|$)
RewriteRule ^ - [S=1]
# Check if this looks like a mobile device
RewriteCond %{HTTP:x-wap-profile} !^$ [OR]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos" [NC,OR]
RewriteCond %{HTTP:Profile} !^$
# Check if we're not already on the mobile site
RewriteCond %{HTTP_HOST} !^m\.
RewriteCond %{QUERY_STRING} !(^|&)mobile=0(&|$)
# Check to make sure we haven't set the cookie before
RewriteCond %{HTTP_COOKIE} !\mobile=0(;|$)
# Now redirect to the mobile site
RewriteRule ^ http://m.mysite.com [R,L]
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ 404.html [F,L]
#
我尝试http://www.mysite.com/?mobile=1并没有发送到移动网站。
这是一个基于 Joomla 1.0 的网站,我安装了 SEO 组件 (sh404sef),但不确定它是否会导致问题。sh404sef 将 url 翻译为 seo 友好的 url。
可以帮忙吗?