Question

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.

Was it helpful?

Solution

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>

OTHER TIPS

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.

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">

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");
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top