1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Stopping a .htaccess file from applying to specific directories

Discussion in 'Apache' started by Andrew_Sam, Aug 10, 2005.

  1. #1
    How do folks?

    I have three Websites hosted by my ISP each each stored in it's own subdirectory off the root. I recently had to add an htaccess file to this root directory to redirect users from an old website address to a new domain I had purchased (again hosted in a sub-directory).

    However this htaccess file is now applying site-wide and across all aliases meaning all three of my sites now point to just one site

    As I understand htaccess files cascade downwards, so that if I have a .htaccess file in my root directory, /,
    and another in a sub-directory called /Wright, then when a file is requested from the /Wright directory Apache will merge the two files and use all the directives.

    Is there any way I can stop this behaviour - I have a 301 redirect in my root directory and I don’t want it to apply to the /Wright sub-directory. I have tried unsuccessfully putting a 301 redirect in the /Wright sub-directory to override the root but this has not been successful.

    Thanks in hopeful anticipation folks
     
    Andrew_Sam, Aug 10, 2005 IP
  2. T0PS3O

    T0PS3O Feel Good PLC

    Messages:
    13,219
    Likes Received:
    777
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Put another htaccess in the deeper folder. It overrides the root one provides you get the order correct in which the directives are executed.

    I had a similar problem and couldn;t crack it until I changed order alllow, disallow.
     
    T0PS3O, Aug 10, 2005 IP
  3. Andrew_Sam

    Andrew_Sam Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the reply TOPS30
    Can I please ask (in basic terms) how do I get the order correct in which the directives are executed? I'm also unsure about your allow/disallow statement if you could clarify please?

    I ask because I tried another .htaccess file in one of the sub-directories, but all that happened when I tried visiting the affected url was the browser hung. It kept trying to open the page but eventually timed out. :(
     
    Andrew_Sam, Aug 11, 2005 IP
  4. Andrew_Sam

    Andrew_Sam Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I should also add that the document root of my old Website and the overall root were the same.
     
    Andrew_Sam, Aug 11, 2005 IP
  5. Willy

    Willy Peon

    Messages:
    281
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You could also replace your Redirect directives with RewriteRules (if you're able to use mod_rewrite on your server). That would allow you to use RewriteConds to determine whether to apply the rules to incoming requests, based on e.g. the URL of the request. In this scenario, you would need only one .htaccess, in the root directory.

    Check the mod_rewrite manual or search this forum for examples...
     
    Willy, Aug 14, 2005 IP