【问题标题】:Redirect ALL requests under a domain to static page [closed]将域下的所有请求重定向到静态页面[关闭]
【发布时间】:2010-11-21 19:49:09
【问题描述】:

我正在尝试重定向对 mydomain.com 的所有请求,无论它们是否类似于:

被重定向到

只要其中包含 mydomain.com,他们应该会看到此页面 - 这是一条我们很快就会回来的消息。

我应该在 .htaccess 或 conf 中进行吗?怎么样?

【问题讨论】:

  • 为什么这是题外话?太糟糕了,我还不能投票。
  • 现在我可以(万岁),碰碰。
  • @bjb568 是的,谁知道;显然,有多个标签专门针对 SO 上的此类问题。我可以理解人们可能更喜欢在 serverfault 上使用它,但是将其称为超出范围是对权威和常识的滥用。 \o/

标签: apache configuration .htaccess redirect


【解决方案1】:

我实际上最终在 ServerFault 上找到了答案:

https://serverfault.com/questions/32513/url-redirect-to-another-page-on-the-same-site

"这个例子会将所有的 URL 302 重定向到 "/underconstruction.html":

RewriteEngine On
RewriteCond %{REQUEST_URI} !=/underconstruction.html
RewriteRule ^ /underconstruction.html [R=302]

(翻译为“如果 URI 不是 /underconstruction.html,则重定向到 /underconstruction.html”)” - Tommeh

【讨论】:

  • 如果这不起作用,请尝试将 apache.conf(在 linux 上:/etc/httpd/conf/httpd.conf)设置 AllowOverride None 更改为 AllowOverride All<Directory "/var/www/html">配置。然后重启apache(在linux上:/etc/init.d/httpd restart)
猜你喜欢
  • 2018-01-06
  • 1970-01-01
  • 2023-04-09
  • 1970-01-01
  • 2013-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多