36

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?

3
  • 6
    Why is this off topic? Too bad I can't cast any reopening votes yet.
    – bjb568
    Oct 23, 2013 at 1:10
  • 1
    Now that I can (hooray), bump.
    – bjb568
    May 14, 2014 at 6:53
  • @bjb568 yea who knows; obviously there are multiple tags specifically for this sort of question on SO. i can understand folks may have a preference to have this on serverfault but calling this out of scope is rather abusive of authority and common sense. \o/ Mar 1, 2016 at 16:56

1 Answer 1

54

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

2
  • 2
    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 ) Sep 27, 2011 at 10:15
  • 1
    This breaks images or css files etc. as all assets are being repointed to the html file.
    – BSUK
    Jul 4, 2022 at 22:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.