Welcome! Log In Create A New Profile

Advanced

How to setup 302 redirect to m.mysite.com for mobile user excluding search bot?

Posted by skyfranky 
How to setup 302 redirect to m.mysite.com for mobile user excluding search bot?
March 30, 2022 07:31AM
Hi

I am runing joomla site www.mysite.com with nginx rewrite
try_files $uri $uri/ /index.php?$args;


I need to setup 302 redirect to m.mysite.com for mobile user excluding search bot. below are the codes I test in vhost

# 1. Only redirect mobile real user to m.mysite.com (WORKING) 2. no redirect for bots using prerender bot detection codes (WORKING) 3. no redirect for non mobile user. (404 ERROR)

location ~/myshop {

set $mobile_redirect 0;
if ($prerender = 0) {
set $mobile_redirect "${mobile_redirect}1";
}
if ($mobile_rewrite = perform) {
set $mobile_redirect "${mobile_redirect}2";
}
if ($mobile_redirect = "012") {
return 302 https://m.mysite.com;
}
try_files $uri $uri/ /index.php?$args;
}

case 3 got 404 error, and I wonder why?

thanks
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 115
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready