LiteSpeed Support Forums

LiteSpeed Support Forums (http://www.litespeedtech.com/support/forum/index.php)
-   Bug Reports (http://www.litespeedtech.com/support/forum/forumdisplay.php?f=9)
-   -   htaccess inheritance (http://www.litespeedtech.com/support/forum/showthread.php?t=4759)

jpipkin 03-01-2011 11:02 PM

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()!

mistwang 03-03-2011 03:29 PM

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

IrPr 03-04-2011 01:42 PM

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\.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

mistwang 03-04-2011 02:39 PM

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.

IrPr 03-04-2011 11:25 PM

Quote:

Originally Posted by mistwang (Post 24194)
We need to follow Apache's behavior even though it may not be a good one.

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

gbutler 03-06-2011 07:54 PM

Quote:

Originally Posted by mistwang (Post 24194)
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.

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.

Regards,

mistwang 03-06-2011 08:23 PM

Quote:

Originally Posted by gbutler (Post 24220)
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.

Regards,

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

IrPr 03-07-2011 11:54 AM

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

any chance to be implemented?

mistwang 03-07-2011 11:59 AM

Quote:

I'm looking forward for "RewriteOptions inherit" directive support
I think it has been supported already. If you find that it does not work properly, let us know.

aledesma 03-07-2011 03:47 PM

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

Originally Posted by mistwang (Post 24248)
I think it has been supported already. If you find that it does not work properly, let us know.

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?

eg:

Code:

<VirtualHost 192.168.0.1>
 ServerName example.com
 DocumentRoot /var/www/example.com/htdocs
</VirtualHost>

Code:

<VirtualHost 192.168.0.1>
 ServerName test.example.com
 DocumentRoot /var/www/example.com/htdocs/test
</VirtualHost>

Will test.example.com ever read the .htaccess from /var/www/example.com/htdocs, or will it start at /var/www/example.com/htdocs/test? I can completely understand the reasoning behind starting at /var/www/example.com/htdocs/test 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.


All times are GMT -7. The time now is 03:24 AM.