Redirecting Urls from the same domain via htaccess

Asked

Viewed 310 times

0

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

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

I tried the following code below in the file .htaccess from my server, but it didn’t 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>

1 answer

0


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

redirect 301 /url-antiga /url-nova

That is, in my case, staying as follows:

redirect 301 /customer-service /central-atendimento

Remember that with this code, it is not necessary to put the base path of your site before the bar. 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>

Browser other questions tagged

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