views:

294

answers:

5

Is there a way to redirect all traffic to my website to a specific page? My free host does support PHP. Not sure if that is what would be appropriate for this or not. Thank you.

A: 

Why don't you just make that page the site's index?

Andrew W.
+1  A: 

If your host is based on Apache and supports mod_rewrite, use that. Eg. the wordpress typical rewite, that redirects requests to non-existing files/folders to index.php, passing on the original URL:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Remus Rusanu
A: 

I'm not sure but meta refresh might work for you

<META http-equiv="refresh" content="0;URL=http://some-url.com/some-page.html"&gt;

FrustratedWithFormsDesigner
A: 

If you can't use .htaccess or mod_rewrite is not available, you can use a simple PHP file:

index.php

<?php
header("Location: http://www.example.com/page");
?>
Peter Sankauskas
+1  A: 

If your host runs Apache and supports .htaccess, add this line to your .htaccess file

ErrorDocument 404 /index.htm

It does not require mod_rewrite. It does assume that only files that are not found will redirect to index.htm.

bmb
But wouldn't this return the result 404 with content /index.html ? If the request is made by an application, the 404 will be considered an error.
Remus Rusanu