好的,我有一个apache IBM HTTP Server WAS 6.1
的设置。
我的证书
已正确安装,并且可以成功加载http
和https
页面。
通过https
进行成功的j_security_check
身份验证后,我希望现在授权的页面(以及所有后续页面)加载为http
。
我希望这一切都能与mod_rewrite
一起工作,因为我不想为了应该在Web服务器上简单实现的事情而更改应用程序代码。
我认为这应该可行,但它并不起作用,我担心是因为j_security_check
以某种方式绕过了mod_rewrite
。
RewriteCond %{HTTPS} =off
RewriteCond %{THE_REQUEST} login\.jsp.*action=init [OR]
RewriteCond %{THE_REQUEST} login\.jsp.*action=submit
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] <<-- this rule is working
RewriteCond %{HTTPS} =on
RewriteCond %{THE_REQUEST} !login\.jsp.*action=init [OR]
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R,L] <--- this rule is not working or the condition is not returning true
我知道
[R,L]
会强制执行规则作为请求中最后一个运行的规则,并相应地进行重定向。我在谷歌上搜索一番后发现了这个小技巧。
mod_rewrite: My rules are ignored. Nothing is written to the rewrite log.
The most common cause of this is placing mod_rewrite directives at global scope (outside of any VirtualHost containers) but expecting the directives to apply to requests which were matched by a VirtualHost container.
In this example, the mod_rewrite configuration will be ignored for requests which are received on port 443:
RewriteEngine On
RewriteRule ^index.htm$ index.html
<VirtualHost *:443>
existing vhost directives
</VirtualHost>
Unlike most configurable features, the mod_rewrite configuration is not inherited by default within a <VirtualHost > container. To have global mod_rewrite directives apply to a VirtualHost, add these two extra directives to the VirtualHost container:
<VirtualHost *:443>
existing vhost directives
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>
将继承声明添加到指向机器IP和端口443的单个虚拟主机声明中并没有帮助解决问题。现在我知道我的应用服务器分别在9080和9443上通信,但是我找不到一个在httpd.conf文件中的虚拟主机。在未经身份验证的情况下,我进行了一些使用不同重写规则的测试,并发现我的mod rewrite代码可以工作。那么,我该如何让WebSphere在身份验证后使用mod rewrite呢?就像Web服务器仅用于未经身份验证的请求一样,之后某个黑盒容器以某种方式提供所有内容。