Redirecting requests with .htaccess

1

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

For example, I have the main site oregionalsul.com.br that is being moved to oregionalsul.com ; the redirection in a simple way I have already been able to do, what happens is that the media loading is done in a subdomain and likewise I need to forward all requests to the .com domain.

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

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

Content is already replicated in both domains, just add or remove .com.br .

See example:

I tried with this topic: URLS redirect , unsuccessfully.

    
asked by anonymous 20.10.2017 / 05:13

1 answer

1

I have been able to resolve this issue for some time, just to provide feedback to the community, follow .htaccess content:

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 panel.

  • Create a subdomain
  • In the list find the subdomain created and click Manage Redirection
  • Fill in the address where you want to redirect and save.
08.10.2018 / 23:18