有没有办法将我网站的所有流量重定向到特定页面?我的免费主机确实支持 PHP。不确定这是否适合于此。谢谢你。
问问题
4397 次
5 回答
2
如果您的主机基于 Apache 并支持mod_rewrite,请使用它。例如。wordpress 典型的重写,将请求重定向到不存在的文件/文件夹到 index.php,传递原始 URL:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
于 2009-10-28T00:31:29.730 回答
1
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.
于 2009-10-28T01:11:16.047 回答
0
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");
?>
于 2009-10-28T00:55:02.583 回答
0
我不确定,但元刷新可能对你有用
<META http-equiv="refresh" content="0;URL=http://some-url.com/some-page.html">
于 2009-10-28T00:41:49.540 回答
0
您必须返回状态码为 301-308 的重定向标头。只考虑使用301,因为浏览器会在你使用301时缓存它
<?php
header("Location: http://www.example.com/about.php",true,302);
exit;
?>
于 2020-12-25T08:34:43.390 回答