Forum Moderators: phranque
I have some problems with mod_rewrite.
First, what I want to do:
My client have to connect with the URL: [mydomain:7777...]
If by mistake, they enter http rather than https, I wand to make a redirection to https.IE [mydomain:7777...] => [mydomain:7777...]
I add the three Rewrite line in ssl.conf and the redirection doesn't work.
Any help welcome
dzi57
httpd.conf file:
LoadModule rewrite_module libexec/mod_rewrite.so
ssl.conf:
Listen 7777
<VirtualHost _default_:7777>
# General setup for the virtual host
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) [mydomain:7777...] [R=301,L]
DocumentRoot "/http/9.0.4/Apache/Apache/htdocs"
ServerName myserver
ServerAdmin you@your.address
ErrorLog "¦/http/9.0.4/Apache/Apache/bin/rotatelogs /http/9.0.4/Apache/Apache/logs/error_log 43200"
TransferLog "¦/http/9.0.4/Apache/Apache/bin/rotatelogs /http/9.0.4/Apache/Apache/logs/access_log 43200"
Port 7777
RewriteCond %{SERVER_PORT} !^443$
Jim
But yet anothe apternative might be to look at the 'tail' of %{THE_REQUEST} to check the request protocol:
RewriteCond %{THE-REQUEST} !HTTPS/[0-9]\.[0-9]+$
Jim
I like it when it is simple!
I can now made some tests on a non production server.
Rewrite rule is ok with your syntax when usin html or https.
It is not Ok when usin http with 443 port.
URL [mydomain...] => Ok
URL [mydomain...] => Ok
URL [mydomain:443...] => Nok with the following error:
[Thu Oct 02 15:50:12 2008] [info] [client 129.181.225.6] SSL handshake failed: HTTP spoken on HTTPS port; trying to send HTML error page
[Thu Oct 02 15:50:12 2008] [info] SSL Library Error: 336027804 error:1407609C:SSL routines:SSL23_GET_CLIENT_HELLO:http request speaking HTTP to HTTPS port!?
Didier
You may now proceed to debug the specific coding issues, having established that mod_rewrite is installed and working.
Jim
Jim
On my opinion there are no solutions for this issue.I have made several tests with always the same result: "SSL handshake failed: HTTP spoken on HTTPS port"
An http request on port 443 (ie:7777) go straight to the Virtual host configure for port 443 (ie:7777). No redirection is possible at this state..
Thanks again
Didier