Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect ALL requests under a domain to static page [closed]

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

  • http://www.mydomain.com
  • http://mydomain.com
  • http://mydomain.com/photos
  • http://mydomain.com/index.php?id=672

to be redirected to

  • http://mydomain.com/index.html

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?

like image 233
barfoon Avatar asked Aug 21 '09 23:08

barfoon


People also ask

How do I make a URL redirect?

Redirects allow you to forward the visitors of a specific URL to another page of your website. In Site Tools, you can add redirects by going to Domain > Redirects. Choose the desired domain, fill in the URL you want to redirect to another and add the URL of the new page destination. When ready, click Create.

How does HTTP redirect work?

In HTTP, redirection is triggered by a server sending a special redirect response to a request. Redirect responses have status codes that start with 3 , and a Location header holding the URL to redirect to. When browsers receive a redirect, they immediately load the new URL provided in the Location header.


1 Answers

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

like image 97
barfoon Avatar answered Sep 23 '22 00:09

barfoon