+ Reply to Thread
Results 1 to 3 of 3

Thread: Forcing SSL through .htaccess

  1. #1
    Join Date
    Jul 2009
    Location
    Los Angeles, CA
    Posts
    2

    Question Forcing SSL through .htaccess

    Hi,

    I came up with the following entries to the file .htaccess.

    Would you please, take a look at it and let me know if something is not right or one line conflicts with another?

    My primary goal is not to allow unsecure (http) access to the website (including the phpBB board).

    Also, I am not sure when to use "www" or not use it in these entries for the .htaccess file. (see below).

    here we go:
    ---------------------------------------------------------------------------
    # Use PHP5 as default
    AddHandler application/x-httpd-php5 .php

    # Do not allow browsing folders without index.html file
    Options -Indexes

    # Force SSL access
    RewriteEngine On
    RewriteCond %{SERVER_PORT} 80
    RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

    # Fixing double-login problem and making sure authorization usernames and passwords are not sent in cleartext unencrypted.
    SSLOptions +StrictRequire
    SSLRequireSSL
    SSLRequire %{HTTP_HOST} eq "example.com"
    ErrorDocument 403 https://example.com
    ---------------------------------------------------------------------------

    Thanks,
    redhost

  2. #2

    Default

    You can use code like this to force a redirect to https:

    RewriteEngine On
    RewriteCond %{SERVER_PORT} !^443$
    RewriteRule ^(.*)$ https://www.domain.de/folder/$1 [L,R]
    The redirect code you currently have doesn't look like it will work.

  3. #3
    Join Date
    Jul 2009
    Location
    Los Angeles, CA
    Posts
    2

    Default

    Thank you for the correction,
    for the rewrite rule, should I use [L,R] or [L,R=301]?
    (I know that the R by itself means R=302, I just don't know which switch to apply in the scenario of redirecting htttp to https)

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts