我有2个版本的网站,桌面和手机:
我的htacces正在将移动设备重定向到移动版。
问题 ...
1-如果访问者来自 google ,因为他搜索了“thing”并且完整链接显示为“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]
答案 0 :(得分: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