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:

  1. Log into cPanel.
  2. Click File Manager.DS_290617_4a22dd
  3. Click the .htaccess file.DS_210617_fed616
  4. Click Edit.DS_210617_a3dede
  5. Find the line RewriteEngine ON. If there isn’t one, create it.
  6. Add below it RewriteRule ^(.*)$$1 [R=301,L]
  7. Click Save Changes.DS_290617_25f8f2

Now everyone who will try to access a webpage on your website will be redirected to the same webpage at

Of course, you should 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 ^(.*)$ [R=301,L].