需要以下方面的apache重写条件帮助:
原始URL:
http://www.test.foo.com/SSO/login?服务=http%3A%2F%2Fwww.bar.com%2Fc%2Fportal%2Flogin
我需要的是:
https://www.test.foo.com/SSO/login?service=http%3A%2F%2Fwww.test.foo.com%2Fc%2Fportal%2Flogin
以下是我的配置:
<VirtualHost *:80>
ServerName www.test.foo.com
ServerAdmin admin@www.test.foo.com
ServerAlias www.test.foo.com
LogLevel warn
ErrorLog /var/log/apache2/www.test.foo.com.error.log
CustomLog /var/log/apache2/www.test.foo.com.access.log combined
ProxyRequests On
ProxyVia On
<Proxy *>
AddDefaultCharset Off
Order deny,allow
Allow from all
</Proxy>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{QUERY_STRING} ^(.*?)www.bar.com(.*)$ [NC]
RewriteRule ^/?(SSO/.*)$ https://www.test.foo.com/$1?%1www.test.foo.com%2 [R,NE,L]
ProxyPass / ajp://localhost:8009/
ProxyPassReverse / ajp://localhost:8009/
</VirtualHost>
通过以上配置,我可以从http重定向到https。现在问题出在请求头位置,我仍在获取
http://www.test.foo.com/SSO/login?服务=http%3A%2F%2Fwww.bar.com%2Fc%2Fportal%2Flogin
有人能帮我或建议我重写条件吗?
您可以在RewriteEngine On
行下方插入此规则:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{QUERY_STRING} ^(.*?)www.bar.com(.*)$ [NC]
RewriteRule ^/?(SSO/.*)$ https://www.test.foo.com/$1?%1www.test.foo.com%2 [R,NE,L]