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.

On a server, how many .htaccess files do you need? (also rewrite?)

Discussion in 'Apache' started by ruven, Jul 10, 2008.

  1. #1
    I know this may sound silly as im instinct would tell me you only need one in the root... but as i go check my site i noticed there was .htaccess files in like 4 different places.

    One at the root where my CMS is located, one in its Admin folder, one in the folder that has my forum installation, and another one somewhere else.
    Most just have a few lines, not much at all... except the one in the root of course.

    Am i right in deleting all those other files?

    My site is www.dailysportspages.com, (although the bulk of the traffic goes to /forums) but folks can also get to it without using the www.... but i read somewhere that its not good to have both addresses doing that. That your users should get to your site from one or the other but not both.

    I read a little bit that using a redirect helps... so i tried doing that in the .htaccess but i ended up doing something wrong because the site stopped coming up when i did that.
    I deleted the file and uploaded a generic file from a site i was reading... maybe you guys could look it over and tell me what other things i would need to add/remove in order to fix this issue. Maybe some other code i could put in there to help with things like speed/cache, SEO, and anti leech protection.

    Im kinda stubborn in wanting to try to figure stuff out myself first, but this stuff doesnt come easy to me and most of my progress is very slow do to much trial and error error error error :D

    Thanks for the help.
     
    ruven, Jul 10, 2008 IP
  2. NatalicWolf

    NatalicWolf Peon

    Messages:
    262
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No. Because one could be for your forums.
     
    NatalicWolf, Jul 11, 2008 IP
  3. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #3
    - You can have as many .htaccess files as you have folders. So every folder can have it's own .htaccess file. Each .htaccess file has some apache directives that can affect other files in that same folder, or subfolders, or files in those subfolders, etc. Those "just a few lines" in some of your .htaccess files could be something very important, without which your forum or some other script on your site might not work properly. Sooo... it depends what does those "few lines" say... but I do not recommend deleting those .htaccess files if you are not 100% sure that you already have everything you need in your main html folder .htaccess file.
    - As for that www. or without www. question... I have all my sites working the same with www. or without www. I don't think I'm experiencing any negative points with Search Engines because of that. I wouldn't change there anything.
     
    pr0t0n, Jul 11, 2008 IP
  4. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    From what I have read in apache manual, you just need only one, and that is on the root folder, despite whatever the dynamic script tells you. Beware, it doesn't mean you should just go delete them, sometimes they are protecting configuration files and folders.

    For example, you install a SEO mod in phpbb, but have a wordpress on the root folder with htaccess first. Apache will read the first one (because your virtual host was set to public_html), that means in your phpBB folder it will break because all the requests are being made as if wordpress was in the phpBB.

    You can pretty much merge all the other htaccess to the one in the root folder, it's just a headache to maintain, plus if it gives you errors in the future remember that it's a bit of a hierarchy. (first execute this directives, then that, then this, etc etc)
     
    Mozzart, Jul 11, 2008 IP
  5. ruven

    ruven Peon

    Messages:
    40
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks for the help guys.
    Unfortunately i did delete one of the files, hopefully im no worse for wear for it.
     
    ruven, Jul 14, 2008 IP