Redirecting a webpage is easy and there are dozens of tutorials on this all over the internet. But why stop there? Sometimes you need to redirect the whole website and doing it page-by-page might not be the smartest way of doing it.
- A website on a hosting with mod_rewrite.
How to redirect a website
There are many ways to do it, but the best one is going straight for the config files:
- Log into cPanel.
- Click File Manager.
- Click the .htaccess file.
- Click Edit.
- Find the line RewriteEngine ON. If there isn’t one, create it.
- Add below it RewriteRule ^(.*)$ http://newdomain.com/$1 [R=301,L]
- Click Save Changes.
Now everyone who will try to access a webpage on your website will be redirected to the same webpage at http://newdomain.com.
Of course, you should http://newdomain.com with your new domain name.
If the webpage naming conventions on your old and new domains are different, you can simply redirect your users to the main page. To do this, replace the line from step 6 with RewriteRule ^(.*)$ http://newdomain.com/ [R=301,L].