How to redirect the old domain to the new one?

Asked

Viewed 140 times

-3

I would like to redirect the old domain to the new one, in the current code is occurring infinite loop.

Follows my code:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Options +FollowSymLinks
RewriteRule (.*) http://novodominio.tk$1 [R=301,L]
</IfModule>

1 answer

1


It’s wrong that, the bar is missing:

  RewriteRule (.*) http://novodominio.tk$1 [R=301,L]

That’s what’s right:

 RewriteRule (.*) http://novodominio.tk/$1 [R=301,L]

I recommend adding a rule to prevent infinite redirect like this:

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Options +FollowSymLinks

#verifica se já está no novo dominio (não adicione http: na frente)
RewriteCond %{HTTP_HOST} !adota-me.tk$ [NC]

#redireciona
RewriteRule (.*) http://adota-me.tk/$1 [R=301,L]

A hint, it is preferable not to use the IfModule in the case of mod_rewrite only, because if the server has not enabled mod_rewrite then you will not notice the error and it will seem that it is a problem in . htaccess when the problem is another, remove the <IfModule mod_rewrite.c> and </IfModule>, and after this try to run . htaccess on a disabled mod_rewrite server it will send the error:

Internal Error Server

This means you need to enable mod_rewrite, so follow the instructions on this link:

Or contact your hosting support

  • gives this error now ERR_TOO_MANY_REDIRECTS

  • @Amadeuantunes I will test.

  • only thing different is Options +Followsymlinks that I did not put because if I put gives this error Internal Server Error The server encountered an Internal error or misconfiguration and was Unable to complete your request. Please contact the server Administrator, [no address Given] and inform them of the time the error occurred, and Anything you Might have done that may have caused the error. More information about this error may be available in the server error log.

  • http://pastebin.com/zetrFAx8

  • thus I have now http://pastebin.com/jEBeQJAW has no error but does not direct

  • rewrite.load is in the mods-enabled file list

  • Internal Server Error The server encountered an Internal error or misconfiguration and was Unable to complete your request. Please contact the server Administrator, [no address Given] and inform them of the time the error occurred, and Anything you Might have done that may have caused the error. More information about this error may be available in the server error log.

  • is making that mistake

  • when doing sudo a2enmod rewrite appears Module rewrite already enabled

  • @Amadeuantunes deletes all . htaccess content and adds only that RewriteEngine On and tells me if it still gives the error "Internal error server"

  • yes gives that error

  • @Amadeuantunes I walked a little away, call me on chat as soon as possible, I do not know if solved your problem with the server

Show 7 more comments

Browser other questions tagged

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