Force SSL on a certain directory

Hi there.

I have a website with a properly installed SSL cert. Now, I would like to setup apache so that all pages in the /members/ folder and sub-folders are forced to https, even if the link to the page or the user types in http.

Is there anyway to do this on the Apache end so that the user cannot disable SSL?

Thank you!

3 Replies

You should be able to do it with an apache rewrite rule (If your using apache).

Something like this in your main server config.

RewriteCond   %{SERVER_PORT}  !^443$
RewriteRule ^/members(.*)$ https://%{HTTP_HOST}/members/$1 [L,R]

Thanks!!

RewriteCond   %{SERVER_PORT}  !^443$
RewriteRule ^/members(.*)$ https://%{HTTP_HOST}/members$1 [L,R]

My slightly modified code, removed a slash.

Yeah ya right, didnt really have time to test it.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct