301 permanent redirect


#1

To redirect any pages from a previous website to the home page of another, which one would be correct in the .htaccess file please? and would anything else be needed in the file?


Redirect 301 / http://www.newdomain.com/

Or:

RewriteEngine on

RewriteBase / RewriteRule (.*) http://www.newdomain.com/$1 [R=301,L]

#2

In case it helps, both domains are on the same server.


#3

The first coding is correct you can use it to redirect your old domain to new one.
Just add the following line in the htaccess file.

Redirect 301 / http://www.newdomain.com/

You can also use the below coding to fix up the issue.

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.example.com [NC]
RewriteRule ^(.*)$ http://example.net/$1 [L,R=301,NC]

Another, the online htaccess file creation using the online tool. Just add your preview domain and your new domain in the and the tool will create the coding.


#4

I would recommend using a 302 temporary redirect while testing because once the permanent redirect is propagated it is extremely difficult to remove.


#6

According to my opinion 1st code is correct for 301 redirection.


closed #7