![]() |
htaccess inheritance
Hello,
We are experiencing an issue on a cPanel/CentOS 64-bit server where .htaccess files do not appear to be inherited. This was occurring with 4.0.19 Enterprise, and, following an upgrade and also a force-reinstall of 4.0.20, is still occurring. given an htaccess file: /home/username/public_html/.htaccess and the rules: RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ /index.php [L] any request for a nonexistent file or directory should be rewritten to a request for index.php. This happens in the given directory. given a subdomain located at: /home/username/public_html/subdomain configured as a vhost in the httpd.conf, the rules are not working; going to a non-existent addresses throws a 404, though the htaccess is getting read in by lsws, according to the logs. If the .htaccess is copied the subdomain directory, it works without issue. On Apache httpd it is working without issue. Here are the relevant log entries (with the bits referring to other rewrite rules in the same htaccess file removed): [/usr/local/apache/conf/httpd.conf:4914] processing direcitve: CustomLog /usr/local/apache/domlogs/subdomain.address.com combined. [/usr/local/apache/conf/httpd.conf:4915] processing direcitve: CustomLog /usr/local/apache/domlogs/subdomain.address.com-bytes_log "%{%s}t %I .\n%{%s}t %O .". [/usr/local/apache/conf/httpd.conf:4918] processing direcitve: suPHP_UserGroup username username. [/usr/local/apache/conf/httpd.conf:4921] processing direcitve: SuexecUserGroup username username. [/usr/local/apache/conf/httpd.conf:4923] processing direcitve: ScriptAlias /cgi-bin/ /home/username/public_html/subdomain/cgi-bin/. [:1] processing direcitve: php_admin_flag display_errors off. [:1] add PHP config: display_errors off [:2] processing direcitve: php_admin_flag safe_mode off. [:2] add PHP config: safe_mode off [:3] processing direcitve: RewriteEngine On. [:3] enable rewrite engine: 1 [:4] processing direcitve: RewriteCond %{ENV:LS_AI_PATH} ^$. [:5] processing direcitve: RewriteRule .*\.php - [F]. [10.1.252.108:64660-0#APVH_subdomain.address.com] Content len: 0, Request line: 'GET /login HTTP/1.1' [10.1.252.108:64660-0#APVH_subdomain.address.com] Cookie len: 238, PHPSESSID=1f4c055877b6b6f8eda238a7384e139f; __utma=219045637.1895141871.1299041193.1299041193. 1299041193.1; __utmb=219045637.10.10.1299041193; __utmc=219045637; __utmz=219045637.1299041193.1.1.utmcsr=(direct)|ut mccn=(direct)|utmcmd=(none) [10.1.252.108:64660-0#APVH_subdomain.address.com] Find context with URI: [/], location: [/home/username/public_html/subdomain/] [HTAccess] Updating configuration file [/home/username/public_html/subdomain/.htaccess] [HTAccess] Updating configuration from [/home/username/public_html/subdomain/.htaccess] [/home/username/public_html/subdomain/.htaccess:1] processing direcitve: Options +FollowSymLinks -Indexes. [/home/username/public_html/subdomain/.htaccess:2] processing direcitve: RewriteEngine on. [/home/username/public_html/subdomain/.htaccess:3] processing direcitve: RewriteBase /. [/home/username/public_html/subdomain/.htaccess:14] processing direcitve: RewriteCond %{REQUEST_FILENAME} !-f. [/home/username/public_html/subdomain/.htaccess:15] processing direcitve: RewriteCond %{REQUEST_FILENAME} !-d. [/home/username/public_html/subdomain/.htaccess:16] processing direcitve: RewriteRule ^(.*)$ /index.php [L]. [10.1.252.108:64660-0#APVH_subdomain.address.com] Find .htaccess context with URI: [/], location: [/home/username/public_html/subdomain/] [10.1.252.108:64660-0#APVH_subdomain.address.com] [REWRITE] Rewrite engine is not enabled for context '/' [10.1.252.108:64660-0#APVH_subdomain.address.com] File not found [/home/username/public_html/subdomain/login] [10.1.252.108:64660-0#APVH_subdomain.address.com] processContextPath() return 25 [10.1.252.108:64660-0#APVH_subdomain.address.com] processNewReq() return 25. [10.1.252.108:64660-0#APVH_subdomain.address.com] HttpConnection::sendHttpError(),code=404 Not Found^M [10.1.252.108:64660-0#APVH_subdomain.address.com] redirect to: URI=[/404.shtml], QueryString=[] [10.1.252.108:64660-0#APVH_subdomain.address.com] Find context with URI: [/], location: [/home/username/public_html/subdomain/] [10.1.252.108:64660-0#APVH_subdomain.address.com] Find .htaccess context with URI: [/], location: [/home/username/public_html/subdomain/] [10.1.252.108:64660-0#APVH_subdomain.address.com] File not found [/home/username/public_html/subdomain/404.shtml] [10.1.252.108:64660-0#APVH_subdomain.address.com] Error Page, processContextPath() return 25 [10.1.252.108:64660-0#APVH_subdomain.address.com] HttpConnection::flush()! [10.1.252.108:64660-0#APVH_subdomain.address.com] Written to client: 617 [10.1.252.108:64660-0#APVH_subdomain.address.com] HttpConnection::nextRequest()! |
this should have been addressed in latest 4.0.20 package.
Please try a force reinstall from LSWS web console, under "Version Managment" page. |
Are you sure that its implemented in Apache?
Lets assume that there is domain.tld VH which contains this rewrites: Code:
RewriteCond %{HTTP_HOST} !^www\.domain\.tldWell, therefore any subdomains such as w00t.domain.tld get redirected into www.domain.tld Also all RewriteRules inherits in deeper subdomain levels For example if its a vBulletin with VBSEO rewrites all php links into vbseo.php which doesn't exists in subdomains and leads to 404 not found for all php files George, i think its wrong feature and would be reverted |
As long as you put a rewrite related directive in subdomain .htaccess, the rewrite rules in parent directory will be ignored. That's the Apache behavior we observed.
Yes, that's true that what you described may cause trouble for subdomains, same for Apache. We need to follow Apache's behavior even though it may not be a good one. |
Quote:
However its default apache's behavior but as you already mentioned its may not be a good idea and LSWS could provide better flexible peformances |
Quote:
Any further advice is much appreciated. Regards, |
Quote:
|
Dear George,
I'm looking forward for "RewriteOptions inherit" directive support any chance to be implemented? |
Quote:
|
Reading .htaccess from parent directory, above child VirtualHost's DocumentRoot
Quote:
Are these separated in the performance (or security) model, to not walk the directory tree up to the DocumentRoot for parent .htaccess files? eg: Code:
<VirtualHost 192.168.0.1>Code:
<VirtualHost 192.168.0.1>An optional flag in Server->General->HT Access for "Apache style inherit" with a warning that it could impact performance would be nice to see. |
| All times are GMT -7. The time now is 03:24 AM. |