LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How to force ssl? (https://www.linuxquestions.org/questions/linux-server-73/how-to-force-ssl-901145/)

decenter 09-04-2011 11:11 PM

How to force ssl?
 
Hello,

I have tried the .htaccess method of forcing ssl. But it never works on my server. I have modrewrite loaded. Any other solution? I need to force the full site to ssl.

anomie 09-04-2011 11:22 PM

You can require SSL with the (appropriately named) directive:
Code:

SSLRequireSSL
That's different than redirecting / rewriting requests from one TCP port to another, though. Any container with the above directive will barf out an HTTP 403 if a non-SSL client attempts to access it.

BTW, I'm assuming you're talking Apache web server? Version 2.2? (That's good info to include in your question.)

decenter 09-04-2011 11:46 PM

Quote:

Originally Posted by anomie (Post 4461654)
You can require SSL with the (appropriately named) directive:
Code:

SSLRequireSSL
That's different than redirecting / rewriting requests from one TCP port to another, though. Any container with the above directive will barf out an HTTP 403 if a non-SSL client attempts to access it.

BTW, I'm assuming you're talking Apache web server? Version 2.2? (That's good info to include in your question.)


yea. It is apache 2.2. Sorry for not giving enough details. But if we use SSLRequireSSL , it will give error page if some one access the http. But, I just need to force ssl.

zhjim 09-05-2011 12:38 AM

Setup a redirect to https://your.site.tld with mod_rewrite. There are a bunch of examples on the net for this.

decenter 09-05-2011 02:03 AM

Quote:

Originally Posted by zhjim (Post 4461689)
Setup a redirect to https://your.site.tld with mod_rewrite. There are a bunch of examples on the net for this.

It goes to infinite redirect loops.

bathory 09-05-2011 02:22 AM

Hi,

Use mod_rewrite:
Code:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

Also make sure that you have
Code:

AllowOverride All
so apache reads the .htaccess file.

Regards

decenter 09-05-2011 08:53 AM

Quote:

Originally Posted by bathory (Post 4461765)
Hi,

Use mod_rewrite:
Code:

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}

Also make sure that you have
Code:

AllowOverride All
so apache reads the .htaccess file.

Regards

Thanks. That worked :)


All times are GMT -5. The time now is 04:25 AM.