[users@httpd] elaborate: htaccess subdirectory, and RewriteOptions behaviours

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm a little curious as to how htaccess files behaves more exactly. I'd like
this email to also serve as an aid to others in the community who are also
more curious about htaccess files, or novices who could avoid a security
pitfall by reading this message.

Throughout, please answer and correct me when wrong, or given options please
elaborate on the correct one and cite why the wrong one is wrong.








Suppose a directory structure exists as such:

(0)          /home/user
(1)          /home/user/public_html
(2)          /home/user/public_html/subdirectory
(3)          /home/user/public_html/subdirectory/subdirectory

Where a particular, but arbitrarly chosen domain, www.somedomain.com, when
accessed, references /home/user/public_html on some server.


As I understand, htaccess rules within subdirectory (2) are inherited from
the parent directory's htaccess files (1) UNLESS an htaccess file exists in
that particular subdirectory (2). Should an htaccess file exist, then,
unless instructed through "RewriteOptions inherit", only the instructions
contained within that htaccess file apply from that directory (2) onward (3,
and so on down). 

If "RewriteOptions inherit" is instructed, then instructions contained
within the htaccess file for directory (2) are merged with instructions from
htaccess from all parent htaccess files (1 then 0) to apply to directories
(2) and (3, onward).

References from where I gather the above conclusions:
http://www.megaton.net/help/htaccess.shtml
http://www.webmasterworld.com/forum92/324.htm





My questions follow:


1. Put .htaccess in user's home directory?:
Is it good practice to put an .htaccess file in a user's home directory?(0).
Would/Do you do this? Why or Why not? Is this a practice anywhere? Can you
provide an example?

I've never thought of this but perhaps it could be useful should a chain of
htaccess files be used.


2. Searching for .htaccess:
How many directories up are searched if a htaccess file is not found in the
current directory and the parent directory? For instance, suppose we are
considering the particular file system structure mentioned earlier but this
time we know:

(0)          /home/user 
             -- has .htaccess file in directory
(1)          /home/user/public_html     
             -- NO .htaccess file
(2)          /home/user/public_html/subdirectory  
             -- NO .htaccess file
(3)          /home/user/public_html/subdirectory/subdirectory 
             -- NO .htaccess file 

Suppose someone points their browser at
http://somedomain.com/subdirectory/subdirectory

Will .htaccess be searched in the directory above public_html? 
How about if /home/user didn't have the htaccess file in the directory
/home/user as indicated above, would apache search /home, and eventually /?



3. "RewriteOptions inherit" behaviour:

In this link
(http://httpd.apache.org/docs/mod/mod_rewrite.html#RewriteOptions), the
following is stated regarding inherit behaviour, "....In per-directory
context this means that conditions and rules of the parent directory's
.htaccess configuration are inherited." 


However, how is htaccess configuration inherited? 

Suppose someone points their browser at
http://somedomain.com/subdirectory/subdirectory

Where the htaccess file has this directive at the top of the file:


RewriteOptions inherit


Where the file system is:
(0')          /home/user 
             -- has .htaccess file in directory
(1')          /home/user/public_html     
             -- has .htaccess file in directory
(2')          /home/user/public_html/subdirectory  
             -- NO .htaccess file
(3')          /home/user/public_html/subdirectory/subdirectory 
             -- has .htaccess file in directory


a. Does the htaccess file in ../subdirectory/subdirectory (3') inherit up
directories until it finds the FIRST htaccess in its path (1') then stop?
Then the rules that apply to the directory ../subdirectory/subdirectory (3')
is the UNION of instructions within .htaccess of the current directory (3')
and the FIRST htaccess found (1').

b. Does the htaccess file in ../subdirectory/subdirectory (3') inherit up
directories until it can go no further in its path (such that it has reached
the / directory? If not, how far up directories does apache search for an
htaccess file?) Then the rules that apply to directory
../subdirectory/subdirectory (3') is the UNION of instructions within
.htaccess of the current directory (3'), the FIRST subsequent htaccess (1)',
the NEXT htaccess file in file hierarchy above (0'), etc until /?


Which of the above two (a) or (b) is correct? If neither please elaborate,
if I've made some judgement error, please elaborate.

  
c. Finally,

Does the placement of the text:
"RewriteOptions inherit"

matter in the htaccess file? Will it matter if this text is placed at the
end of an htaccess file instead of the top?



RewriteOptions inherit reference:
http://tsunami.in.force-elite.com/httpd-dev/199610.mbox/%3c199610051419.AA09
322@xxxxxxxxx%3e




Regards,

Krystian.



PS. There's an unanswered message with some similar queries to mine posted
long ago on comp.infosystems.ww.servers.unix. A link follows:
http://groups-beta.google.com/group/comp.infosystems.www.servers.unix/browse
_thread/thread/929862236cf5e850/3f099c36360d69c2?q=htaccess+subdirectory&rnu
m=9#3f099c36360d69c2



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
   "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux