Let's talk now.
407-476-6930 / 850-366-8392 (PCB)

Redirect All Pages to a Single URL/Page

by Brandon Welch
Web Designer/Developer & Web Expert
Connect with me: | Facebook | LinkedIn

At times you might need to temporary redirect all pages on your website to a single page or url.

Example: The website needs to be taken down for maintenance. I have even seen this used as promotional tactic for sales, etc.

With a quick edit to your .htaccess file, you can do this!

How To Do It

Open up your .htaccess file, and add in the following code.
Note: If this change is just temporary, note the “302” in the code below. “301” would mean permanent.


<IfModule mod_rewrite.c>
RewriteRule temporarypage.php$ - [L] RewriteRule ^(.*)$ http://yourdomainname/temporarypage.php [R=302,L] </IfModule>

Additional Info: [L] means last rule processed. Therefore, if that rule matches the regular expression, all rules after it would not be run. Without it, temporarypage.php would continue to redirect to itself over and over again (which wouldn’t happen, your server would yell at you).

Shout out to Jete Okeeffe (System Admin Extraordinary) for helping us out with this one! You are the best!