apache如何从自定义端口重定向到https协议?

时间:2012-05-26 23:50:15

标签: protocols apache

如何将http://secure.domain.com:444重定向到https://secure.domain.com:444

使用此代码时出现400(错误请求)错误:

RewriteEngine
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

提前致谢。

编辑:

这是完整的配置:

    Listen 444
    NameVirtualHost ip:444

    <VirtualHost ip:444>
            ServerName secure.domain
            DocumentRoot "/var/www/.phpmyadmin/3.5.1/"

            RewriteEngine On
            RewriteCond %{HTTPS} !=on
            RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

            SSLEngine on
            SSLProtocol all -SSLv2
            SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM

            SSLCertificateFile /etc/httpd/conf/domain.crt
            SSLCertificateKeyFile /etc/httpd/conf/domain.pwdless.key
            SSLCertificateChainFile /etc/httpd/conf/sub.class1.server.ca.pem
            SSLCACertificateFile /etc/httpd/conf/ca.pem

            <Directory "/var/www/.phpmyadmin/3.5.1/">
                    Options None
                    AllowOverride None
                    Order allow,deny
                    Allow from all
                    AuthType Basic
                    AuthName "Restriected Access"
                    AuthUserFile "/var/www/.phpmyadmin/.access"
                    Require valid-user
            </Directory>
    </VirtualHost>

    <VirtualHost ip:444>
            ServerName domain
            ServerAlias *.domain
            RedirectMatch 404 ".*"
    </VirtualHost>

1 个答案:

答案 0 :(得分:0)

这是不可能的。服务器设置为仅接受该端口上的SSL请求。有一个RFC支持您要求的内容(RFC 2817),但普通浏览器不支持它。 Chrome bug tracker中的故障单上有一些链接。