.htaccess blocking a port on a directory

Discussion in 'Apache' started by rincewind, Mar 20, 2007.

  1. #1
    Hello.

    I've got this virualhost that is accesseble both through http (port 80)and https (port 443).

    Yet in that documentroot I have one directory that I only whant to be accessable through https (port 443) and not port 80..

    I have OptFollowSymlinks up and running and working perfectly

    What I want is this:
    /www/mysite/* <-- Accessable from from both p80 and p443
    /www/mysite/security/* <---- Only accessable p443

    Can I block with /www/mysite/security/.htaccess port 80? And how do I do that?

    Does anyone know?=)

    Mvh
    -- Jon
     
    rincewind, Mar 20, 2007 IP
  2. oziman

    oziman Active Member

    Messages:
    199
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #2
    This is what I use for an entire domain.. It should work on the subdirectory by adding ReWriteBase /sub... Tell me if it doesn't work.
    
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /secure
    RewriteCond %{SERVER_PORT} !443$
    RewriteRule (.*) https://www.blahblah.com/$1 [R=301,L]
    Code (markup):
     
    oziman, Mar 20, 2007 IP
  3. rincewind

    rincewind Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Is it possible to only do this from the .htaccess file?? The site is realy live and a lot of people on it.. Dont wanna reload the apache..?
     
    rincewind, Mar 20, 2007 IP
  4. oziman

    oziman Active Member

    Messages:
    199
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    Yes this is meant to be done within the directory. It should work right away, no restart needed.

    I like Terry Pratchet, too.
     
    oziman, Mar 21, 2007 IP
  5. ThreeGuineaWatch

    ThreeGuineaWatch Well-Known Member

    Messages:
    1,489
    Likes Received:
    69
    Best Answers:
    0
    Trophy Points:
    140
    #5
    In those instances a "graceful" restart of your httpd will not disconnect people.

    And it should not need a restart provided the Override FileInfo is set (otherwise the .htaccess file will be ignored)
     
    ThreeGuineaWatch, Mar 23, 2007 IP