Redirecting URLs from the same domain via htaccess

0

I would like to direct through htaccess two url of the same domain, type 301. Example:

Redirect meusite.com.br/customer-service to meusite.com.br/central-atendimento

I tried the following code in the file .htaccess of my server, but it did not work:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^http://meusite.com.br/customer-service [NC]
    RewriteRule ^(.*)$ http://meusite.com.br/central-atendimento$1 [L,R=301]
</IfModule>
    
asked by anonymous 06.07.2018 / 16:31

1 answer

0

The solution to this problem is quite simple. In the .htaccess file of your server, just enter the following code below:

redirect 301 /url-antiga /url-nova

That is, in my case, it looks like this:

redirect 301 /customer-service /central-atendimento

Remembering that with this code, it is not necessary to put the base path of your site before the slash. Another thing is that the code should be placed inside a tag:

<IfModule mod_rewrite.c></IfModule>

Example in my case:

<IfModule mod_rewrite.c>
    redirect 301 /customer-service /central-atendimento
</IfModule>
    
09.07.2018 / 20:47