Redirect requests with . htaccess

Asked

Viewed 38 times

1

I urgently need a simple and practical way to redirect via . htaccess preferably to an alternate domain of a website. This practice is to adopt SEO measures, since there are several media already indexed by Google and other search engines.

Exemplifying, I have the main site oregionalsul.com.br which is being moved to oregionalsul.com; the redirect in a simple way I have already managed to do, what happens is that the media loading is done in a subdomain and in the same way I need to forward all the requests to the domain .com.

The relative path of a media is as follows:

https://midia.oregionalsul.com.br/2017/10/segunda_etapa_da_transferencia_de_carga_da_ponte_hercilio_luz_20171010_1160690858-1132x670.jpg

that is, I need everything that comes after midia.oregionalsul.com.br is redirected to the same address only in the domain .com.

The content is already replicated in both domains, just add or remove the .com.br.

See example:


I tried with this topic: Redirecting of Urls, unsuccessful.

1 answer

1


I was able to resolve the issue some time ago, just to offer feedback to the community, follows content from .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^midia\.oregionalsul\.com\.br$ [OR]
RewriteCond %{HTTP_HOST} ^www\.midia\.oregionalsul\.com\.br$

RewriteRule ^(.*)$ "https\:\/\/midia\.oregionalsul\.com\/$1" [R=301,L]

Using a 301 redirect you can do this. If your hosting is CPANEL, do it directly on the dashboard.

  • Create a subdomain
  • In the listing find the created subdomain and click on Manage Redirection
  • Fill in the address you want to redirect to and save.

Browser other questions tagged

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