Doubt with htaccess file

0

Hello, everyone!

I have a question regarding my .htaccess file. It turns out that I have a site in two versions, common and mobile. In the mobile file folder, there is the .htaccess file 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]

In this way, when trying to access the " link " link through a desktop, for example, it is directed to the url main.

So far so good.

The problem is the reverse. In the root folder of the site, in the .htaccess file I put it like this:

 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 it is not working.

Is there an error in this file?

Abcs

    
asked by anonymous 06.09.2016 / 23:02

1 answer

1

Do so in htaccess of 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>

just change the redirect url link I use this on my site and it's ok

    
07.09.2016 / 00:15