Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Hi I have configured Virtual host on apache with .htaccess authentication with SSL. It's working fine when I typed url but when I typed I am getting this error:

Bad Request

Your browser sent a request that this server could not understand.
Reason: You're speaking plain HTTP to an SSL-enabled server port.
Instead use the HTTPS scheme to access this URL, please.

My httpd.conf file look like this:

 Listen 9004
<VirtualHost *:9004>
    ServerAdmin root@localhost
    DocumentRoot /mnt/work/httpd
    <Directory "/mnt/work/httpd">
    Options FollowSymLinks
     AllowOverride AuthConfig
  SSLEngine On
  SSLCertificateKeyFile /mnt/work/httpd/
  SSLCertificateFile /mnt/work/httpd/
#RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*){REQUEST_URI}
    ErrorLog "/mnt/work/log/error_log"
    CustomLog "/mnt/work/log/access_log" combined

And my /etc/httpd/conf.d/ssl.conf file is:

LoadModule ssl_module modules/

# When we also provide SSL we have to listen to the
# the HTTPS port in addition.
Listen 9006

And Mmy .htaccess file is:

AuthType Digest
AuthName "Protected"
AuthDigestProvider file
AuthGroupFile /dev/null
AuthUserFile /mnt/work/httpd/digest_auth
Require user johan

What should I do so that when I hit http:/ it will automatically redirect to

share|improve this question

2 Answers 2

It seems you want 9004 for https; 9006 for http; You should redirect http connection on 9004 port to https connection on same 9004 port.

However your config redirects to which does not make much sense since 9006 port is for http. Just replace 9006 by 9004 in your RewriteRule.

Some additional info on url redirection:

share|improve this answer
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Should do the trick.

share|improve this answer
Hi Its not Working Same error Occurred Bad Request... –  Akki May 16 '13 at 9:25

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.