Doubt with htaccess file

Asked

Viewed 59 times

0

Hello, everybody!

I have a question regarding my HTACCESS file. I happen to have a site in two versions, common and mobile. In the folder of the mobile file, there is the file . htaccess that receives the following code:

RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile) [NC]
RewriteRule ^$ http://www.meusite.com.br/ [L,R=302]

This way, when trying to access the link "http://meusite.com.br/mobile" through a desktop, for example, it is directed to the main url.

So far so good.

The problem is in the reverse. In the root folder of the site, in the file . htaccess put as follows:

 RewriteCond %{HTTP_USER_AGENT} (android|blackberry|ipad|iphone|ipod|iemobile|opera\ mobile|palmos|webos|googlebot-mobile) [NC]
RewriteRule ^$ http://www.meusite.com.br/mobile [L,R=302]

With this, the user when trying to access the main link through a mobile, should be directed to the mobile directory, but is not working.

Is there an error in this file?

Abçs

1 answer

0

Does so in the htaccess of the web version

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|ipad|iphone|ipod|opera mobile|palmos|webos" [NC]
   RewriteRule ^$ http://m.example.com/ [L,R=302]
</IfModule>

only changes the redirect url link use this on a site of mine and is ok

  • Hello Jasar, I did as you suggested. When opening the default url through a mobile, it worked perfectly, redirecting to the mobile version. The problem is that when testing on the desktop, it also directs to mobile.

  • strange just tested here and ta normal. vc tested with which browsers?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.