当我访问mydomain.com时,移动重定向会起作用,但当我转到其他某些页面时,它会失败并提供原始链接。
location / {
if ($http_user_agent ~* "(iPhone|iPod|android|blackberry)" ) {
return 301 $scheme://$host/m$request_uri;
}
index index.php;
}
location /m/ {
index index.php;
}
有什么帮助吗?
我尝试了这个,但后来我最终得到了一个重定向循环
location ~ /page\.php.* {
if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino") {
return 301 /m$request_uri;
}
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}