Webmaster Sun Login
Not a member yet? Sign up

How many htaccess files should i have?

  • HOME
  • FORUMS
  • WHAT'S NEW
  • BLOGS
  • MARKETPLACE
  • ADVERTISING
  • SPECIAL OFFERS
  • WEB HOSTING
  • QUICK MENU
  • REGISTER HERE - Join us for FREE
Results 1 to 15 of 15
    Stick this thread
  1. #1
    Join Date
    Jan 2017
    Posts
    164
    Thumbs Up/Down
    Received: 6/0
    Given: 20/0
    Thanks
    2
    Thanked 4 Times in 4 Posts

    How many htaccess files should i have?

    I was looking at some information on .htaccess files and some things that can be done with them but I am not sure if all of the things that I have been thinking about doing with them can be done with just one .htaccess file or if there should or can be multiples.

    Does anyone know how many .htaccess files should i have?

  2. #2
    Join Date
    May 2014
    Location
    India
    Posts
    1,056
    Thumbs Up/Down
    Received: 244/5
    Given: 119/3
    Thanks
    32
    Thanked 99 Times in 88 Posts
    You can only create one .htaccess file for a website. This is the rule. because file manager do not allow you to create multiple .htaccess files. If you create multiple than it will overwrite your existing file.
    Blogging Tips & Tricks @ Blogwithvk.com

  3. #3
    Join Date
    May 2016
    Location
    USA
    Posts
    1,732
    Thumbs Up/Down
    Received: 529/1
    Given: 28/1
    Thanks
    13
    Thanked 216 Times in 199 Posts
    You can have 1 htaccess file per folder on your website. You can have 1 in the root public_html folder and 1 in each sub folder and sub folder of a sub folder etc.

  4. #4
    Join Date
    Jan 2017
    Posts
    164
    Thumbs Up/Down
    Received: 6/0
    Given: 20/0
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by vishwa View Post
    You can only create one .htaccess file for a website. This is the rule. because file manager do not allow you to create multiple .htaccess files. If you create multiple than it will overwrite your existing file.
    I saw someone saying something about multiple htaccess files and wasn't sure what they meant. I thought they might have meant multiple versions like updates.

    Quote Originally Posted by Rob Whisonant View Post
    You can have 1 htaccess file per folder on your website. You can have 1 in the root public_html folder and 1 in each sub folder and sub folder of a sub folder etc.
    So as long as they are in separate folders then you can have a different one for each folder?

  5. #5
    Join Date
    May 2016
    Location
    USA
    Posts
    1,732
    Thumbs Up/Down
    Received: 529/1
    Given: 28/1
    Thanks
    13
    Thanked 216 Times in 199 Posts
    Quote Originally Posted by Zack View Post
    So as long as they are in separate folders then you can have a different one for each folder?
    Yes. Just keep in mind that an htaccess file acts on the folder it is in and any sub folders that don't have an htaccess file in them.

    Don't make things difficult though. Keep it simple. The majority of sites that need htaccess only need 1 file in the root folder. If it's a membership site, then 1 in the members area folder also.

  6. #6
    Join Date
    Jan 2017
    Posts
    164
    Thumbs Up/Down
    Received: 6/0
    Given: 20/0
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by Rob Whisonant View Post
    The majority of sites that need htaccess only need 1 file in the root folder. If it's a membership site, then 1 in the members area folder also.
    Thanks Rob.

    Why would a membership site need more? Is it to restrict access to certain areas or for some other reason?

  7. #7
    Join Date
    May 2016
    Location
    USA
    Posts
    1,732
    Thumbs Up/Down
    Received: 529/1
    Given: 28/1
    Thanks
    13
    Thanked 216 Times in 199 Posts
    Quote Originally Posted by Zack View Post
    Thanks Rob.

    Why would a membership site need more? Is it to restrict access to certain areas or for some other reason?
    Yes, it would be to restrict access to members only.

  8. #8
    Join Date
    Feb 2017
    Posts
    2
    Thumbs Up/Down
    Received: 0/0
    Given: 0/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can upload only 1 htaccess file. .htaccess file is a configuration file used by Apache-based web servers that control access of web crawlers.

  9. #9
    Join Date
    May 2016
    Location
    USA
    Posts
    1,732
    Thumbs Up/Down
    Received: 529/1
    Given: 28/1
    Thanks
    13
    Thanked 216 Times in 199 Posts
    Quote Originally Posted by Nikita Patil View Post
    You can upload only 1 htaccess file. .htaccess file is a configuration file used by Apache-based web servers that control access of web crawlers.
    This is not true. You can upload one in every folder on the website. They also control a LOT more than just control crawlers access to your site. Go search out some htaccess tutorials and study them. You will be amazed at what can be done with them.

  10. #10
    Join Date
    Jul 2012
    Posts
    39
    Thumbs Up/Down
    Received: 7/0
    Given: 6/0
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Have as many .htaccess as you require. I think there is no limit.
    .htaccess in subdirectories can override RewriteRules of the parent directory .htaccess. Just add line: "RewriteEngine On" in "child" .htaccess to do so.

    /home/john/public_html/.htaccess < parent / root folder of the web
    /home/john/public_html/admin/.htaccess < child / subfolder
    Last edited by postcd; 03-22-2017 at 07:55 AM.

  11. #11
    Join Date
    Jan 2017
    Posts
    164
    Thumbs Up/Down
    Received: 6/0
    Given: 20/0
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by postcd View Post
    Just add line: "RewriteEngine On" in "child" .htaccess to do so.
    I've seen that and didn't know what it meant. Basically it just means that the code below overrides whatever code is in the parent folders?

  12. #12
    Join Date
    Jul 2012
    Posts
    39
    Thumbs Up/Down
    Received: 7/0
    Given: 6/0
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Zack: It will override only rewrite rules (RewriteRule, RewriteCond) of your parent htaccess. I am not aware of any method that would stop inheriting everything from parent htaccess.

  13. #13
    Join Date
    Jan 2017
    Posts
    164
    Thumbs Up/Down
    Received: 6/0
    Given: 20/0
    Thanks
    2
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by postcd View Post
    Zack: It will override only rewrite rules (RewriteRule, RewriteCond) of your parent htaccess. I am not aware of any method that would stop inheriting everything from parent htaccess.
    Oh, alright. Thanks for the info. I don't know enough about these things yet so a lot of this just has me lost.

  14. #14
    Join Date
    Feb 2017
    Location
    UK
    Posts
    62
    Thumbs Up/Down
    Received: 40/0
    Given: 18/0
    Thanks
    1
    Thanked 4 Times in 4 Posts
    htaccess is very powerful when used properly and has a lot of action you can do from site optimization to website access etc.

    Most sites use mainly 1 at the root to cater for all sub folders then an additional ones would be made to protect certain directories like a secure downloads folder to a members only or staff only area.

    have a bit of a research on how to use them as they are very useful.

    As a note you are never restricted to just 1 per site its actually 1 per folder and it will cater for all sub directories unless another one is put in place to override its parent directory settings.

  15. #15
    Join Date
    Apr 2016
    Location
    United States
    Posts
    578
    Thumbs Up/Down
    Received: 355/0
    Given: 38/0
    Thanks
    29
    Thanked 171 Times in 122 Posts
    Listen to Rob above, he has it explained perfectly.

    This is a question that comes up frequently in my college classes and I could not have explained it better and more succinct then Rob just did.

    Don't make your web development life more difficult then it needs to be.

    One in the public_html folder, this will pertain to all folders that do not have their own .htaccess and as Rob recommended for security reasons and file access limitations if you have a membership site, one in the members folder. This will normally have different configuration commands then the root folder based on what your members are allowed to do.

    Do some reading on these file types. There are a lot of commands that can be included in the .htaccess file, many more than most people realize. Just remember test them before you upload them to a live site because with all that power, and they can be quite powerful, you can do a lot of damage, not physical but access wise, to your site if you do not understand the proper use of the commands.

    Great explanation Rob.
    Mike
    Learn Web Development - OnLine Video Training OnTargetHTML5
    Have Questions On Training or Web Development: Contact Mike

Newer Threads

  1. Zack
    Seller
    Replies: 5 | Views: 1658
    Last post by Seller, 03-06-2017, 02:10 AM
  2. ricky_
    HostaPolis
    Replies: 4 | Views: 1673
    Last post by HostaPolis, 03-12-2017, 04:37 AM
  3. Rob Whisonant
    Seller
    Replies: 6 | Views: 1242
    Last post by Seller, 03-15-2017, 08:37 AM
  4. ricky_
    w3master
    Replies: 6 | Views: 1490
    Last post by w3master, 03-09-2017, 12:04 PM

Older Threads

  1. Mick M
    daniel27lt
    Replies: 2 | Views: 1482
    Last post by daniel27lt, 02-25-2017, 01:26 AM
  2. paul1129
    KarenByerly
    Replies: 6 | Views: 1523
    Last post by KarenByerly, 02-19-2017, 05:48 PM
  3. norled
    norled
    Replies: 2 | Views: 2577
    Last post by norled, 03-01-2017, 10:02 AM
  4. earmoldsydney
    Hello
    By earmoldsydney in forum New Member Introductions
    BestProxies
    Replies: 6 | Views: 1732
    Last post by BestProxies, 03-03-2017, 10:56 AM
  5. Seller
    vishwa
    Replies: 4 | Views: 1796
    Last post by vishwa, 02-18-2017, 11:32 AM

Latest Threads

  1. HostXNow
    HostXNow
    Replies: 0 | Views: 93
    Last post by HostXNow, 10-10-2019, 02:16 PM
  2. HostXNow
    HostXNow
    Replies: 0 | Views: 100
    Last post by HostXNow, 10-10-2019, 02:12 PM
  3. PaymentGateway
    PaymentGateway
    Replies: 3 | Views: 105
    Last post by PaymentGateway, Today, 05:12 AM
  4. arindamb
    ethelglover
    Replies: 1 | Views: 176
    Last post by ethelglover, 10-12-2019, 04:39 AM
  5. arindamb
    vishwa
    Replies: 1 | Views: 132
    Last post by vishwa, 10-09-2019, 05:56 AM

Similar Threads

  1. john
    onliveserver
    Replies: 1 | Views: 2501
    Last post by onliveserver, 06-30-2017, 10:55 AM
  2. JerryJo
    JerryJo
    Replies: 0 | Views: 2723
    Last post by JerryJo, 04-09-2013, 04:31 AM
  3. fantaseo
    fantaseo
    Replies: 0 | Views: 1212
    Last post by fantaseo, 04-01-2013, 02:39 AM
  4. RobertClive
    HostNurse
    Replies: 1 | Views: 1882
    Last post by HostNurse, 02-24-2013, 08:26 AM
  5. Dmoz
    Eddy88
    Replies: 2 | Views: 3311
    Last post by Eddy88, 07-30-2012, 10:43 AM

Posting Permissions

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

Internet Marketing Forum

Webmaster Sun is a forum where you’ll find in-depth discussions and resources to help you succeed on the web whether you are new or experienced. You’ll find it all here. With topics ranging from internet marketing, search engine optimization, social networking, make money online, web hosting, affiliate marketing as well as hands-on technical support for web design, programming and more. We are a growing community of like-minded people that is keen to help and support each other with ambitions and online endeavors. Learn and grow, make friends and contacts for life.

Come Hang Out With Us

    Facebook Twitter Webmaster Forum Google+

    Webmaster Sun Logo
Copyright ©2012 - 2019, WebmasterSun.com. All rights reserved. Internet marketing forum for internet marketers, webmasters, web hosting providers, designers and affiliate marketers.

Welcome to Webmaster Sun

The World's Number 1 Webmaster Community, SEO and Marketplace

Log in!

Continue with Facebook
Continue With Email. By signing up you indicate that you have read and agree to the Terms of Service and Privacy Policy.

Sign in Manually

Need an account? Sign up now!