Redirect ALL requests under a domain to static page

62,251

I actually ended up finding the answer on ServerFault:

https://serverfault.com/questions/32513/url-redirect-to-another-page-on-the-same-site

"This example will 302 redirect all URLs to "/underconstruction.html":

RewriteEngine On
RewriteCond %{REQUEST_URI} !=/underconstruction.html
RewriteRule ^ /underconstruction.html [R=302]

(which translates as "If URI is not /underconstruction.html, redirect to /underconstruction.html")" - Tommeh

Share:
62,251
barfoon
Author by

barfoon

PHP & iOS developer based out of Ottawa.

Updated on July 09, 2020

Comments

  • barfoon
    barfoon almost 4 years

    I am trying to redirect ALL requests for mydomain.com whether they are something like:

    to be redirected to

    As long as it has mydomain.com in it, they should see this page - its a we'll be back soon message.

    Should I do it in .htaccess or conf? How?

  • T. Brian Jones
    T. Brian Jones over 12 years
    If this does not work at first, try changing the apache.conf (on linux: /etc/httpd/conf/httpd.conf ) setting AllowOverride None to AllowOverride All inside the <Directory "/var/www/html"> configuration. Then restart apache ( on linux: /etc/init.d/httpd restart )