.htaccess 基于htaccess的移动设备检测
我使用以下链接创建了一个可用的移动应用程序:.htaccess 基于htaccess的移动设备检测,.htaccess,symfony1,symfony-1.4,.htaccess,Symfony1,Symfony 1.4,我使用以下链接创建了一个可用的移动应用程序: www.mysite.com/mobile.php 我的问题是在我使用网站www.mysite.com的链接时检测移动版本,并使用htaccess将我重定向到我的移动应用程序www.mysite.com/mobile.php的链接 我注意到应用程序是用Symfony1.4开发的 在我的移动应用程序的所有布局中,我在顶部使用以下html代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict
www.mysite.com/mobile.php
我的问题是在我使用网站www.mysite.com
的链接时检测移动版本,并使用htaccess将我重定向到我的移动应用程序www.mysite.com/mobile.php
的链接
我注意到应用程序是用Symfony1.4开发的
在我的移动应用程序的所有布局中,我在顶部使用以下html代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
编辑:
这是我修改后的访问权限:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^(%2d|-)[^=]+$ [NC]
RewriteRule ^(.*) $1? [L]
</IfModule>
Options +FollowSymLinks +ExecCGI
<IfModule mod_rewrite.c>
RewriteEngine On
# uncomment the following line, if you are having trouble
# getting no_script_name to work
RewriteBase /
# we skip all files with .something
#RewriteCond %{REQUEST_URI} \..+$
#RewriteCond %{REQUEST_URI} !\.html$
#RewriteRule .* - [L]
# we check if the .html version is here (caching)
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
# no, so we redirect to our front web controller
RewriteRule ^(.*)$ index.php [QSA,L]
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iphone|ipad|android|blackberry [NC]
RewriteRule ^$ /mobile.php
</IfModule>
重新启动发动机
重写cond%{QUERY_STRING}^(%2d |-)[^=]+$[NC]
重写规则^(.*)1美元?[L]
选项+FollowSymLinks+ExecCGI
重新启动发动机
#如果遇到问题,请取消对以下行的注释
#无法使用脚本名称
重写基/
#我们跳过了所有的文件
#重写条件%{REQUEST_URI}\+$
#重写条件%{REQUEST\u URI}!\。html$
#重写规则。*-[L]
#我们检查.html版本是否在这里(缓存)
重写规则^$index.html[QSA]
重写规则^([^.]+)$$1.html[QSA]
重写cond%{REQUEST_FILENAME}-F
#不,所以我们重定向到前端web控制器
重写规则^(.*)$index.php[QSA,L]
重新启动发动机
重写cond%{HTTP_USER_AGENT}iphone | ipad | android | blackberry[NC]
重写规则^$/mobile.php
但它不起作用
我不希望出现什么非常困难的情况,我希望更改上面的htaccess以实现这种情况:
我可以访问链接www.mysite.com
(在两种情况下使用相同的链接):
1-要查看我的主要站点,默认情况下,在前端控制器index.php
上的htaccess point
2-如果我访问移动版本,htaccess将检测到它,并将我指向前端控制器
mobile.php
,将我直接重定向到app mobile。您可以通过
您可以在下面我的第一条消息中看到修改,请…@Nll您必须将规则放在最前面,否则主页将被重写为
index.html
,而此规则将永远不会被考虑。因此,请使用我的htaccess更改上面的代码,并用代码解释我。。。
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} iphone|ipad|android|blackberry [NC]
RewriteRule ^$ /mobile.php