How to redirect all pages of a website to homepage

redirect-to-home

In this tutorial I will explain how to redirect your website visitors to homepage for any url of your website. Its very helpful when you have your website under maintenance or you have just homepage.

Step 1:

Create a blank text file in public_html folder and rename it as .htaccess
If you already have a .htaccess file in public_html folder, make a backup of this file and delete all codes from it.

Step 2:

Copy paste below code in .htaccess file and save it.

RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.(gif|jpg|jpeg|png|css|js)$
RewriteRule (.*) / [R=301,L]

Done!!!

Our Top Rated Host

Related Posts