http always to https

Started by casi91, December 21, 2012, 11:54:16 AM

Previous topic - Next topic

casi91

Hi Community,
i want to redirect every http request to https.

I found the "mod_rewrite" for this problem, but it doesn't work.

I tried it in a many ways,
hier some of them:

RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^/(.*)$ https://www.site.de [R=301,L]



RewriteEngine On
RewriteCond %{SERVER_PORT} ^!443
RewriteRule ^/(.*)$ https://%{SERVER_NAME}%{REQUEST_URI}  [R=301,L]



RewriteEngine On
RewriteCond %{SERVER_PORT} ^!443
RewriteRule (.*)$ https://%{SERVER_NAME}%{REQUEST_URI}  [R=301,L]



RewriteEngine On
RewriteCond %{SERVER_PORT} ^80$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]


can somebody help me?

Jan-E

Within the <VirtualHost for port 80>

   <IfModule mod_rewrite.c>
      RewriteEngine on
      RewriteCond      %{HTTP_HOST}   ^(example.com|www.example.com)$
      RewriteRule ^/(.*)   https://www.example.com/$1 [R,L]
   </IfModule>
</VirtualHost>

casi91

Thanks for your answer

I did it with "redirect", but how you said, within the virtual host.

<VirtualHost for port 80>
....
Redirect permanent / https://www.site.de
</VirtualHost>