htaccess inheritance

Discussion in 'Bug Reports' started by jpipkin, Mar 2, 2011.

  1. jpipkin

    jpipkin New Member


    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:

    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:

    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/ combined.
    [/usr/local/apache/conf/httpd.conf:4915] processing direcitve: CustomLog /usr/local/apache/domlogs/ "%{%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].
    [] Content len: 0, Request line: 'GET /login HTTP/1.1'
    [] 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)|utmccn=(direct)|utmcmd=(none)
    [] 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].
    [] Find .htaccess context with URI: [/], location: [/home/username/public_html/subdomain/]
    [] [REWRITE] Rewrite engine is not enabled for context '/'
    [] File not found [/home/username/public_html/subdomain/login]
    [] processContextPath() return 25
    [] processNewReq() return 25.
    [] HttpConnection::sendHttpError(),code=404 Not Found^M
    [] redirect to:
    [] Find context with URI: [/], location: [/home/username/public_html/subdomain/]
    [] Find .htaccess context with URI: [/], location: [/home/username/public_html/subdomain/]
    [] File not found [/home/username/public_html/subdomain/404.shtml]
    [] Error Page, processContextPath() return 25
    [] HttpConnection::flush()!
    [] Written to client: 617
    [] HttpConnection::nextRequest()!
  2. mistwang

    mistwang LiteSpeed Staff

    this should have been addressed in latest 4.0.20 package.
    Please try a force reinstall from LSWS web console, under "Version Managment" page.
  3. IrPr

    IrPr Well-Known Member

    Are you sure that its implemented in Apache?

    Lets assume that there is domain.tld VH which contains this rewrites:
    RewriteCond %{HTTP_HOST} !^www\.domain\.tld
    RewriteRule (.*) http://www.domain.tld/$1
    Which forces to www links with redirection

    Well, 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
    Last edited: Mar 4, 2011
  4. mistwang

    mistwang LiteSpeed Staff

    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.
  5. IrPr

    IrPr Well-Known Member

    Is it possible to have an option for disabling inheritance behavior for subdomains like before?
    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
    Last edited: Mar 5, 2011
  6. gbutler

    gbutler New Member

    A force-reinstall was done and verified version is 4.0.20. However, with NO .htaccess file present in the sub-directory, rewrite rules are not inherited from .htaccess in parent directory. Have also tried creating a .htaccess in sub-directory with only "RewriteEngine on" and "RewriteOptions inherit" to no avail...

    Any further advice is much appreciated.

  7. mistwang

    mistwang LiteSpeed Staff

    It must be something else, add "RewriteLogLevel 9" to subdomain configuraiton in httpd.conf, restart, then check error_log.
  8. IrPr

    IrPr Well-Known Member

    Dear George,
    I'm looking forward for "RewriteOptions inherit" directive support

    any chance to be implemented?
  9. mistwang

    mistwang LiteSpeed Staff

    I think it has been supported already. If you find that it does not work properly, let us know.
  10. aledesma

    aledesma New Member

    Reading .htaccess from parent directory, above child VirtualHost's DocumentRoot

    The issue, as I am seeing it right now, is that the VirtualHost is not honoring the .htaccess in the parent directory (which is a different VirtualHost) as cPanel created the directory hierarchy.

    Are these separated in the performance (or security) model, to not walk the directory tree up to the DocumentRoot for parent .htaccess files?


     DocumentRoot /var/www/
     DocumentRoot /var/www/
    Will ever read the .htaccess from /var/www/, or will it start at /var/www/ I can completely understand the reasoning behind starting at /var/www/ for performance or even for security, but I am not sure if that fits in with the Apache methods that are expected (where every directory from / on up to the cwd are checked for an .htaccess).

    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.
  11. mistwang

    mistwang LiteSpeed Staff

    try "Force Reinstall" 4.0.20 from LSWS admin console "Version Management".
  12. aledesma

    aledesma New Member

    force reinstall 4.0.20

    Please know that jpipkin, gbutler and myself are all from the same company. We have performed a force reinstall before the initial post, and again in post #6. I have again performed a force reinstall, with no discernible changes seen.

  13. mistwang

    mistwang LiteSpeed Staff

    We have tested it in our lab under cPanel vhosts, it works fine.
    Please add "RewriteLogLevel 9" to subdomain configuration, then post debug log like that in the first post, we will analyze what happens.
    Sorry, I am not smart enough to figure out all of your three are from the same company.
  14. aledesma

    aledesma New Member

    The RewriteEngine, within the parent itself, was not being inherited from the global declaration. After adding RewriteEngine on into the parent .htaccess it does appear as though the rewrites are working as intended.

    Thank you for your patience,

Share This Page