Redirecting with htaccess

Asked

Viewed 219 times

1

I need to do a direction when the user accesses, https://www.dominio.com.br/portal/qualquercoisa is directed to https://www.dominio.com.br/blog

You can do this with . htaccess?

It follows code I possess:

<ifModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_METHOD} OPTIONS
    RewriteRule .* / [R=200,L]
    RewriteRule ^portal/([a-z0-9\-]+)/$ ^blog/ [QSA]
</ifModule>

Note: Inside the portal folder, I already have an index.php directing to blog. This . htaccess would go inside this folder.

1 answer

1


Inside the . htaccess file that is inside the public_html/ folder of your account, just add the line below:

RewriteCond %{HTTP_HOST} ^domínio\.com\.br$ [OR]
RewriteCond %{HTTP_HOST} ^www\.domínio\.com\.br$
RewriteRule ^/?$ "http\:\/\/domínio\.com\/pastaredirecionada\/" [R=301,L]

This redirect is more complex and indicates (in the example above) that the domain "domain.com.br" (without quotation marks) will redirect to "domain.com/redirected/" (without quotation marks). Can be without the folder too.

Browser other questions tagged

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