[英].htaccess to redirect specific index file when particular url is visited
我有一個網站網址http://t8.example.info/home.html
,當我在移動版本中打開該網址時,我想將此網址重定向到http://t8.example.info/index.php?id=802
。 在桌面版本中打開時,我不想重定向。 它應該像在桌面版本中一樣打開。
需要快速幫助。 提前致謝
不了解htaccess,但您可以通過javascript實現
var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent);
if (isMobile) {
window.location = "http://t8.example.info/index.php?id=802";
}
最后我找到了一個解決方案,我在.htaccess文件中使用以下代碼
RewriteCond %{REQUEST_URI} /home.html$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^/?(.*)$ http://t8.example.info/index.php?id=802 [L,R=302]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.