Redirect URL to mobile version with . htaccess

Asked

Viewed 305 times

0

I’m making the mobile version of a website and I need it to redirect any page to its mobile version:

Ex: If the accessed page is: https://www.website.com.br/seguranca should redirect to https://www.website.com.br/m/seguranca

And so to all others.

Obs:

  1. I don’t know much about . htaccess.
  2. I didn’t make the website.
  3. From what I’ve noticed, the . htaccess is making the "urls system friendly" to the site.

Current file:

# Ativa o suporte à reescrita
RewriteEngine On

Options +FollowSymLinks

#============== Para colocar o www se a url não tiver
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

#============= Para colocar barra no final da URL que não tiver
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{REQUEST_URI} !(.*)/$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1/ [L,R=301]


# Não aplica a condição para arquivos
RewriteCond %{SCRIPT_FILENAME} !-f

# Não aplica a condição para diretórios
RewriteCond %{SCRIPT_FILENAME} !-d

# Regra de reescrita onde qualquer string (.*) após a pasta, 
# onde estiver o .htaccess, será interpretado por index.php passado na variável cod
RewriteRule ^(.*)$ index.php?par=$1

1 answer

0

You can use htaccess’s 301 redirect. It is very simple to do this, just specify the Redirect 301 and pass two information, the first is the old url and the other is the new url to be permanent.

Ex:

Redirect 301 /home-antiga /m/home-nova 

Browser other questions tagged

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