与htaccess的维护页面转发并不能为代理的材料工作并不、能为、页面、材料

2023-09-02 00:54:39 作者:重度臆想症

我已经冲刷互联网,很茫然,为什么我的维护页面重定向和重写规则不会对任何代理材料或任何通过HTTPS来了跨越工作。

I have scoured the internet and am at a loss as to why my maintenance page redirect and rewrite rules do not work for any proxied material or anything that is coming across through https.

我使用Apache 2.2.3服务器上安装的Tomcat 6.0.24。

I am using an Apache 2.2.3 server with tomcat 6.0.24 installed on it.

我有以下htaccess文件:

I have the following htaccess file:

Options +FollowSymlinks
RewriteCond %{REQUEST_URI} !/maintenance.html
RewriteCond %{REQUEST_URI} !/images/(.*)$
RewriteCond %{REQUEST_URI} !/scripts/(.*)$
RewriteCond %{REQUEST_URI} !/styles/(.*)$

RewriteCond %{REMOTE_ADDR) !^123.456.789.100

RewriteRule $ /maintenance.html [R=302,L]

它重定向我所有的HTTP页面维护页面我的图片,脚本和所有的和样式正常工作。然而,它不是重定向它们是从另一台机器代理任何https网页

It redirects all of my http pages to the maintenance page and all of my images, scripts, and styles work properly. However, it is not redirecting any https pages which are proxied from another machine.

所以 http://mypage.com/documents 重定向到维护,其中的 https://mypage.com/users 不重定向。

So http://mypage.com/documents redirects to maintenance where as https://mypage.com/users does not redirect.

不幸的用户来说是一个代理服务,生活后端服务器,而单据上的前端服务器上的静态页面。

Unfortunately users is a proxied service that lives on a backend server whereas documents is a static page on the front end server.

有没有办法来强制代理的和/或https材料被重定向呢?还是我能够禁用的mod_proxy在我htaccess,因此,没有什么被代理?

Is there a way to force proxied and/or https material to be redirected as well? Or am I able to disable mod_proxy in my htaccess file so that nothing gets proxied?

推荐答案

检查SSL虚拟主机正在读的.htaccess 文件(的AllowOverride无指令)。 避免的.htaccess 文件中像瘟疫。这是一个动态的配置文件。配置(Apache中的文件)的休息是静态的,使得表演有很大的区别。但它是不相关的: - ) 在某些指令需要别人precedences,有一个优先级的为了执行的。而在本文档的链接,你可以看到任何代理指令的任何目录指令前阅读(和htaccess的是子子子目录指令)​​。所以,如果您的代理是由mod-rewritep标签中的.htaccess不处理(反正什么坏主意),它之前应用和机会是你的.htaccess是从来不看(你所要求的代理,没有本地文件阅读,因此阿帕奇没有本地目录中读取,所以阿帕奇并不需要解析来自一个不存在的目录中的所有现有的.htaccess文件和他的父母)

Check your SSL virtualhost is reading .htaccess files (AllowOverride None directive). Avoid .htaccess file like plague. It's a dynamic configuration file. Rest of the configuration (in apache files) is static, makes a big difference in performances. But it's unrelated :-) Some directives takes precedences on others, there is a priority in the order of execution. And in this documentation link you can see any Proxy directive is read before any Directory directive (and a .htaccess is a sub-sub-sub directory directive). So If your proxy is not handled by a mod-rewrite P tag in a .htaccess (what a bad idea anyway) it's applied before and chances are your .htaccess is never read (you are asking for a proxy, there is no local file to read, so Apache has no local directory to read, so apache do not need to parse all existing .htaccess files from a non-existent directory and all his parents)

在解决方案,如果你能真正的编辑配置文件,是使用重定向在虚拟主机级别,而不是在一个目录(或的.htaccess)或位置。因此,这将是始终应用​​

On solution, if you can edit real configuration files, is to use a redirection in the VirtualHost level, not in a Directory (or .htaccess) or Location. So that it will be always applied:

ErrorDocument 503 /htdocs/err/maintenance.html
## uncomment below to enter maintenance mode
RedirectMatch 503 ^/(?!err/|images/|scripts/)

我通常使用一个simplier形式在/ ERR子目录的元素,而重定向都没有这个子目录来一个503错误。在503,然后由维护页在此犯错子目录处理。在这里,我已经添加了图片/ 脚本/ 子目录好,没考恩pression但它应该工作,我想。

I usually use a simplier form with only elements in /err subdirectory, and redirecting everything not in this subdirectory to a 503 error. The 503 is then handled by the maintenance page in this err subdirectory. Here I have added the images/ and scripts/ subdirectories as well, did not test the expression but it should work, I think.