0

我有 2 个版本的网站、桌面版和手机版:

  1. www.olivashot.com
  2. www.mobile.olivashot.com

我的 htacces 正在将移动设备重定向到移动版本。

问题... _

1-如果访问者来自谷歌,因为他搜索了“东西”,完整链接显示为“www.olivashot.com/index.php/thing”,它重定向到“www.mobile.olivashot.com/index .php/thing"(我有一个快乐的访客)

2-但如果谷歌中的链接是:“www.olivashot.com/thing”>>>他被重定向到“www.mobile.olivashot.com”(我失去了一个访问者,因为我没有展示他的内容预期的)

我认为这是因为我正在重写“某事”以退出 joomla 网站中的默认“index.php”

RewriteBase /

## Begin - Joomla! core SEF Section.
#
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
#
# If the requested path and file is not /index.php and the request
# has not already been internally rewritten to the index.php script

RewriteCond %{REQUEST_URI} !^/index\.php
# and the request is for something within the component folder,
# or for the site root, or for an extensionless URL, or the
# requested URL ends with one of the listed extensions
RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$ [NC]
# and the requested path and file doesn't directly match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# and the requested path and file doesn't directly match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# internally rewrite the request to the index.php script
RewriteRule .* index.php [L]
#
## End - Joomla! core SEF Section.




RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://www.mobile.olivashot.com/$1/ [R=301,L]
4

1 回答 1

2

您应该将最后一个块放在具有一些退出点的 Joomla 自定义重定向之前。这意味着顺序应该是:

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://www.mobile.olivashot.com/$1/ [R=301,L]


## Begin - Joomla! core SEF Section.
...

您可以删除该行RewriteEngine On它已在文件顶部启用。为了增加安全性,一旦您开始工作,您可以查看样板模板的 .htaccess 文件 h5bp.com

于 2013-04-30T09:31:27.393 回答