/ / Redirecionar usuário móvel para subdiretório móvel enquanto mantém o caminho usando o Htaccess - .htaccess, redirecionar, móvel, caminho

Redirecionar Usuário Móvel para Subdiretório Móvel Mantendo o Caminho Usando o Htaccess - .htaccess, redirecionamento, mobile, caminho

Eu tenho esse código que funciona perfeitamente, mantendo o caminho que eu quero:

RewriteEngine On

RewriteCond %{HTTP_HOST} !^m.example.com$

RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]

RewriteCond %{HTTP_COOKIE} !mobilecookie=true

RewriteRule ^(.*)$ http://m.example.com%{REQUEST_URI} [L,R=302]

mas quero que o usuário móvel seja redirecionado para example.com/m que é a pasta onde estão os arquivos do site móvel

No momento, ele está redirecionando o usuário móvel para m.example.com mantendo o caminho, mas quero que o usuário móvel passe example.com para example.com/m mantendo o caminho.

Alguém pode me dizer onde adicionar o diretório nesse código?

Respostas:

0 para resposta № 1

Para redirecionar para uma subpasta, o arquivo .htaccess deve ser como;

RewriteEngine On
RewriteBase /

# Your line to replace "get" with "got". It will replace get.php with got.php.php. Following line must be either "RewriteRule ^get(.*) /got.php" or "RewriteRule ^get(.*) /got$1"
RewriteRule ^get(.*) /got.php$1

# You are redirecting example.com to www.example.com. But your mobile site URL is http://example.com/m. So, there must be a control which excludes mobile agents.
RewriteCond %{http_host} ^example.com [nc]
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile) [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]

RewriteCond %{HTTP_HOST} ^11.222.33.44 [nc]
RewriteRule ^(.*)$ http://www.example.com/$1 [r=301,nc]

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

# Add /m to URI for mobile agents (if it hasn"t added yet)
RewriteCond %{REQUEST_URI} !^[/]?m [NC] [OR]
RewriteCond %{HTTP_USER_AGENT} android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile [NC]
RewriteRule ^(.*)$ http://example.com/m/$1 [QSA,L]

BrowserMatchNoCase "Apache-HttpClient" bots

Order Allow,Deny
Allow from ALL
Deny from env=bots

RewriteCond %{HTTP_USER_AGENT} libwww-perl.*
RewriteRule .* – [F,L]

ErrorDocument 404 /index.php