将域下的所有请求重定向到静态页面

bar*_*oon 32 apache .htaccess configuration redirect

我试图重定向mydomain.com的所有请求,无论它们是这样的:

被重定向到

只要它有mydomain.com,他们应该看到这个页面 - 我们将很快回复消息.

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

bar*_*oon 51

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

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

"此示例将302将所有网址重定向到"/underconstruction.html":

RewriteEngine On
RewriteCond %{REQUEST_URI} !=/underconstruction.html
RewriteRule ^ /underconstruction.html [R=302]
Run Code Online (Sandbox Code Playgroud)

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

  • 如果一开始不起作用,请尝试更改 apache.conf (在 Linux 上: /etc/httpd/conf/httpd.conf )将 `<Directory "/var/www/ 内的 `AllowOverride None` 设置为 `AllowOverride All` html">`配置。然后重新启动apache(在linux上:/etc/init.d/httpd restart) (2认同)