好的我有一个 apache IBM HTTP Server WAS 6.1 setup

我正确安装了 certs ,可以成功加载 http https 页面。

通过 https 成功验证 j_security_check 后,我希望现在授权的页面(以及所有后续页面)加载为 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] 会强制执行的规则成为请求上运行的最后一条规则并相应地重定向。

我在一点点google之后找到了这个小宝石。

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声明添加到指向机器ip和端口443 的单个 virtualhost 声明中没有任何帮助。

现在我知道我的app服务器分别在 9080 9443 上进行通信,但我在Web服务器中找不到一个 virtualhost <代码>的httpd.conf

我使用不同的重写规则进行了一些测试,但没有经过身份验证,看到我的 mod rewrite 代码工作了..

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

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

有帮助吗?

解决方案

这是http到https到http

的解决方案

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

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>

其他提示

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

RewriteCond %{THE_REQUEST} !login\.jsp.*action=init
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top