Skip to content

Redirect all pages to new domain with Htaccess

Last updated on November 25, 2022

if you want to change your domain name without affecting SEO Ranking in search engines then you should think about the 301-page redirect, with a 301 redirect you can move your web application to a new domain freely.

we can use different methods for setting 301 redirects from the old domain to the new domain but I am gonna use .htaccess. this method is most preferred, effective, and easy.

create the .htaccess file in your old website root folder then put the below lines in the .htaccess file.

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

Here, this one redirects everything after the domain name on the URL to the exact same copy on the new domain URL., for example, arjun.net.in/drag-drop-file-upload-dropzone-js-codeigniter/ will redirect to arjunphp.com/drag-drop-file-upload-dropzone-js-codeigniter/.

if you remove $1 , all pages redirect to the home page Ex: arjunphp.com. this will affect search engine rankings.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments