问题
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.
回答1:
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>
回答2:
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.
回答3:
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">
回答4:
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");
?>
来源:https://stackoverflow.com/questions/1634511/how-to-redirect-all-web-traffic-to-a-specific-page