Go Back   vb.org Archive > Community Discussions > Forum and Server Management
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 10-17-2019, 05:12 PM
alfuzzy alfuzzy is offline
 
Join Date: Jul 2018
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default htaccess File Help

My server setup has multiple .htaccess files (which I'm guessing may be normal).

Server setup is public_html directory...then forums sub-directory. Both the public_html directory & forums sub-directory each have a .htaccess file.

My questions are:

1. How do each of these .htaccess files work together (if they do)?
2. Should each of them contain the exact same information...or should the higher up public_html directory have less/more info...or should the lower sub-forums directory have more/less info in it?

I'm sure I will have follow up questions...but wanted to get these 2 out of the way first.

Thanks
Reply With Quote
  #2  
Old 10-18-2019, 12:37 AM
final kaoss final kaoss is offline
 
Join Date: Apr 2006
Posts: 1,314
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Basically what you need to know is that a .htaccess file in a parent directory will affect all child folders of it. So knowing this, you can set your rules as needed.
Reply With Quote
  #3  
Old 10-18-2019, 01:11 PM
alfuzzy alfuzzy is offline
 
Join Date: Jul 2018
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by final kaoss View Post
Basically what you need to know is that a .htaccess file in a parent directory will affect all child folders of it. So knowing this, you can set your rules as needed.
Thanks final kaoss...what you said makes sense.

Thus here are two hypothetical situations...anyone please let me know if what I'm stating makes sense (or not):

1. If an .htaccess file in a parent directory effects all child folders or directories in it. In theory..does it make sense that a child directory could have more rules or more restrictions than the parent directory?

2. In theory...could a parent & child directory have exactly the same .htaccess file rules...and everything work fine (basically both parent & child directory have exactly the same duplicated .htaccess file)?

And here's one additional question. Looking at my websites server setup...is it basically a given that almost all parent & child directories have an .htaccess file? Most of mine do...but I do see some that don't.

Thanks
Reply With Quote
  #4  
Old 10-18-2019, 02:15 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1. A child directory inherits the parent .htaccess rules and you can apply additional rules to the child .htaccess file as well.
2. If the child directory has no .htaccess file then it will inherit the parent .htaccess file. However keep in mind that, depending on the rules that have been defined in the parent .htaccess file, it might not match in the child directory.

Whether or not you need a .htaccess file in all directories depends entirely on your configuration and needs.
Reply With Quote
  #5  
Old 10-18-2019, 03:10 PM
alfuzzy alfuzzy is offline
 
Join Date: Jul 2018
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks Dave. Some followup questions:

Quote:
Originally Posted by Dave View Post
1. A child directory inherits the parent .htaccess rules and you can apply additional rules to the child .htaccess file as well.
Let's say (in theory) a child directory didn't need any additional rules compared to the parent directory.

Could the child directory run properly without any .htaccess file at all...or would the child directory need it's own .htaccess file & it would look exactly the same as the parent directory .htaccess file?

Quote:
Originally Posted by Dave View Post
2. If the child directory has no .htaccess file then it will inherit the parent .htaccess file. However keep in mind that, depending on the rules that have been defined in the parent .htaccess file, it might not match in the child directory.
Let's say the parent directory had 7 rules in it's .htaccess file...and a website owner wanted the child directory to have 3 additional .htaccess rules. Would the child directory's .htaccess file ONLY need the 3 extra rules stated...or would the child directory need to have all 10 rules stated (7 from the parent directory & the 3 additional child directory rules)?

Quote:
Originally Posted by Dave View Post
Whether or not you need a .htaccess file in all directories depends entirely on your configuration and needs.
I know that .htaccess files can do a lot of things...I believe one of the primary things .htaccess files can do is "allow" and "deny" certain traffic into a directory based on IP address/IP address range. Where the .htaccess file is sort of acting like a doorway into the directory. Is this sort of true?

The .htaccess files for my site contain a lot of "rewrite" rules as well...which I guess I need to learn more about in general...and how they are working specifically for my site.

Thanks
Reply With Quote
  #6  
Old 10-18-2019, 03:22 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Yes, the child directory can run without its own .htaccess file if it meets the parent .htaccess rules. If you add 3 rules in a .htaccess file in the child directory, it will inherit the parent rules and load the 3 additional rules.

The most popular feature of .htaccess is "RewriteRule" where if a certain condition is met, it redirects either the user or request internally to a different script or page. You can also deny access based on IP addresses like you said. The rewrite rules are commonly used for clean URL's. For example a page at example.com/category/subcategory/productname might rewrite the URL behind the scenes to example.com/index.php?route=category/subcategory/productname where the framework that runs behind the scenes parses the URL and further processes it to show the proper page.

Here is a good source for you https://httpd.apache.org/docs/curren.../htaccess.html
Reply With Quote
  #7  
Old 10-18-2019, 03:32 PM
alfuzzy alfuzzy is offline
 
Join Date: Jul 2018
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks again Dave.

Quote:
Originally Posted by Dave View Post
Yes, the child directory can run without its own .htaccess file if it meets the parent .htaccess rules. If you add 3 rules in a .htaccess file in the child directory, it will inherit the parent rules and load the 3 additional rules.
I understand some of this...but get lost a little bit with the statement "If it (the child directory) meets the parent .htaccess rules".

I guess I was thinking that if the child directory didn't have it's own .htaccess file...then there would be no rules for the child directory not to meet...and thus access to the child directory would be the same as the parent directory. But then again...I guess there are all sorts of .htaccess rules...more than just access related.

Quote:
Originally Posted by Dave View Post
Thanks a bunch for the link...I really want to learn more about .htaccess files & what they can & cannot do. If there are any additional good/great links...please post.

Thanks again.
Reply With Quote
  #8  
Old 10-18-2019, 04:51 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

For example the .htaccess rules in the parent directory might have a rule such as "if the URL contains /some/directory, redirect to location X" but this rule might never be met in the child directory.

Here are 2 more good sources for you: http://www.htaccess-guide.com/ and https://code.tutsplus.com/tutorials/...iles--net-4757
Reply With Quote
  #9  
Old 10-18-2019, 06:37 PM
alfuzzy alfuzzy is offline
 
Join Date: Jul 2018
Posts: 168
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Awesome. Thanks for the links Dave.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:33 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.07628 seconds
  • Memory Usage 2,248KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (9)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete