#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2003
    Posts
    3
    Rep Power
    0

    Auto Forward From HTTP to HTTPS?


    I'm setting up a SSL secured part of my web site. Now most people are used to typing "subdomain.domain.com" in the address bar. If I use SSLRequireSSL for this site, they'll normally get a 403 error. Users: Huh?

    What I did to combat this is in my .htaccess:

    ErrorDocument 403 https://subdomain.domain.com

    Is this appropriate/recommended? Is it possible that this will result in an endless loop. If this doesn't work, what kind of error should I expect in return? 500?

    Thanks
  2. #2
  3. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    mod_rewrite might be a better solution if available.
    Code:
    RewriteEngine On
    RewriteRule ^(.*)$ https://subdomain.domain.com/$1 [R,L]
    # Jeremy

    Explain your problem instead of asking how to do what you decided was the solution.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    2
    Rep Power
    0
    You'll need a RewriteCond or something or it will just loop. I'm looking for a solution myself and can't get it to work. The closest suggestion is this from wirespeed, but it does not include the path/filename.

    What I want is a rewriterule that automatically rewrites something like

    http://abc.def/ghi/jkl.htm

    to

    https://abc.def/ghi/jkl.htm
  6. #4
  7. mod_dev_shed
    Devshed Supreme Being (6500+ posts)

    Join Date
    Sep 2002
    Location
    Atlanta, GA
    Posts
    14,817
    Rep Power
    1100
    I guess the RewriteRule I wrote works for me b/c I have separate folders for my http and https docs, so if I put that rule in .htaccess in my http folder, when it rewrites, it's not in my https folder.

    For those without this server structure, check the SERVER_PROTOCOL.
    Code:
    RewriteEngine On
    RewriteCond %{SERVER_PROTOCOL} ^[^https]$ [NC]
    RewriteRule ^(.*)$ https://subdomain.domain.com/$1 [R,L]
    The regular expression ^[^https]$ may need a little tweaking as I'm not entirely sure what all is returned as the protocol.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Posts
    4
    Rep Power
    0
    You can use RewriteCond %{SERVER_PORT} ^443$. Example can be found here

    >> RewriteRule ^(.*)$ https://subdomain.domain.com/$1 [R,L]

    This could lead to a external redirect to https://subdomain.domain.com// (double slash) because ^(.*)$ portion has no slash.

    BTW, just because you are asking about HTTPS does not mean it is a security question. You should still post this kind of topic to Apache forum.
    Last edited by freebsd; March 14th, 2003 at 03:34 PM.
  10. #6
  11. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2003
    Posts
    2
    Rep Power
    0
    Works fine as an addition in httpd.conf but I can't get it to work in a .htaccess file.

    I've got "Options +FollowSymLinks" and things like "ErrorDocument" and other stuff works in .htaccess.

    If the forum is inappropriate maybe a Mod could move the thread to wherever it belongs. It's the same to me, I use search anyway

IMN logo majestic logo threadwatch logo seochat tools logo