3

好的,我有一个apache IBM HTTP Server WAS 6.1设置

我已经certs正确安装并且可以成功加载httphttps页面。

通过 成功j_security_check验证后https,我希望现在授权的页面(以及所有后续页面)加载为http.

我希望这一切都可以使用,mod_rewrite因为我不想更改应用程序代码,而这些代码在网络服务器上确实应该很简单。

我认为这会起作用,但它不起作用,我担心这是因为以某种方式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>

将 Inherit 声明添加到我virtualhost的指向机器 ip 的单个声明中并且port 443没有任何帮助。

现在我知道我的应用服务器分别在9080和上进行通信,但我在 web 服务器中9443找不到一个。virtualhosthttpd.conf

我在未经过身份验证的情况下使用不同的重写规则进行了一些测试,发现我的mod rewrite代码有效..

那么:如何让 websphere 在身份验证后使用 mod 重写?

就像 Web 服务器仅用于未经身份验证的请求,然后某个黑盒容器以某种方式提供所有内容。

4

2 回答 2

0

这是http到https到http的解决方案

您必须像文章所说的那样将条件和重写规则放在虚拟主机中,但由于某种原因,继承不想工作。

RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /path/login\.jsp\ HTTP/1\.1
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

   <VirtualHost 000.000.000.000:443>
    ServerName servername
    ServerAlias url.com machinename
    DocumentRoot d:/ibmhttpserver61/htdocs/en_US
    ErrorLog d:/ibmhttpserver61/logs/secerr.log
    TransferLog d:/ibmhttpserver61/logs/sectrans.log
    SSLEnable
    Keyfile d:/ibmhttpserver61/ssl/ctxroot.kdb
    SSLV2Timeout 100
    SSLV3Timeout 1000 

    RewriteEngine On
    RewriteCond %{REQUEST_URI} /path/secure/index.jsf
    RewriteRule ^(.*)$ http://url/path/secure/index.jsf [R,L]    

    </VirtualHost>
于 2008-10-31T14:44:12.203 回答
-1

大胆猜测:第二个逻辑 OR 是否应该是 AND(即没有 [OR] 并且 RewriteCond 默认为 AND)?

RewriteCond %{THE_REQUEST} !login\.jsp.*action=init
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
于 2008-10-30T21:44:16.073 回答