[Resolved].htaccess php_value and php_flag being ignored in sub-directory

Status
Not open for further replies.

Mike Yo.

Active Member
#1
I have an .htaccess in my public_html directory with the following rules:
Code:
<IfModule litespeed>
 php_flag zlib.output_compression On
 php_value zlib.output_compression_level 2
  php_value session.gc_maxlifetime 200000
 php_flag display_startup_errors On
 php_flag html_errors On
 php_flag ignore_repeated_errors Off
 php_flag ignore_repeated_source Off
 php_flag report_memleaks On
 php_flag track_errors On
 php_value log_errors_max_len  0
 php_flag display_errors Off
 php_flag log_errors On
 php_value error_log  errors.log
 php_value max_execution_time 600
 php_value max_input_time 600
 php_value max_input_vars 100000
</IfModule>
They are working fine, confirmed through phpinfo();

However, when I am placing .htaccess in a sub-directory, with rules that suppose to override the above, they are being completely ignored, and only the above rules are working.

For example, I have placed an .htaccess file in my public_html/admin directory, with the following rules
Code:
<IfModule litespeed>
 php_value session.gc_maxlifetime 7200
 php_flag display_errors On
</IfModule>
When checking phpinfo(); it shows that the values are still "200000" and "Off" instead of "7200" and "On" respectively.

Why does this happen and how can I fix it?
 
Last edited by a moderator:

NiteWave

Administrator
#2
I did a simple test and it looks working as expected.

first, ensure
http://php.net/manual/en/configuration.changes.php
You will need "AllowOverride Options" or "AllowOverride All" privileges to do so.
Code:
public_html/.htaccess
<IfModule litespeed>
php_value max_execution_time 600
php_value max_input_time 600
</IfModule>

public_html/subdir/.htaccess
<IfModule litespeed>
php_value max_execution_time 1200
php_value max_input_time 1200
</IfModule>
when access http://website/phpinfo.php
Code:
max_execution_time 600(Local Value) 30(Master Value)
max_input_time 600(Local Value) 60(Master Value)
when access http://website/subdir/phpinfo.php
Code:
max_execution_time 1200(Local Value) 30(Master Value)
max_input_time 1200(Local Value) 60(Master Value)
test env:
lsws 5.0.16
lsphp 5.6.20
native virtual host
lsphp running as nobody
 
Last edited by a moderator:

Mike Yo.

Active Member
#4
That's odd, isn't
Code:
<Directory "/home/user/public_html/">
    AllowOverride All
</Directory>
supposed to cover also AllowOverride of /home/user/public_html/sub-folder/
 
Last edited by a moderator:

Mike Yo.

Active Member
#5
I am asking this because I had to specifically set AllowOverride in httpd.conf to make it work.
Doesn't <Directory "/home/user/public_html/"> apply to the entire tree under it?



<Directory "/">
AllowOverride All
Options ExecCGI FollowSymLinks IncludesNOEXEC Indexes SymLinksIfOwnerMatch
</Directory>

<Directory "/home/user/public_html/">
AllowOverride All
</Directory>

<Directory "/home/user/public_html/admin/">
AllowOverride All
</Directory>


<Directory "/usr/local/apache/htdocs">
Options All
AllowOverride None
Require all granted
</Directory>

<Files ~ "^error_log$">
Order allow,deny
Deny from all

Satisfy All
</Files>

<Files ".ht*">
Require all denied
</Files>
 

Pong

Administrator
Staff member
#6
Yes, AllowOverride is supposed to cover the entire tree. I believe there could be some other directives preventing the inheritage. So no harm to enable .htaccess for a sub folder specifically.
 

Mike Yo.

Active Member
#7
It's not about the harm, it's about the fact that it's very inconvenient to need to set AllowOverride for every single sub-directory.
How can I check what's the directive that's preventing the sub-folder from overriding the upper level .htaccess?
 
Last edited:
L

Long

Guest
#8
Hi,
Are you using OpenLiteSpeed or ENT lsws?
If it's ENT, what's the htaccess settings in lsws server setting General page?
I just tested here with exactly the same .htaccess content from your first post and it's working perfectly fine.
I used lsws native settings and no httpd.conf.
Allow Override for htaccess setting set to:
Limit
Auth
FileInfo
Indexes
Options
None
 

Pong

Administrator
Staff member
#10
Since LiteSpeed works as expected with httpd.conf and .htaccess through lab test, you will have to find out which directives in httpd.conf disabling your .htaccess in subdirectory.
 
L

Long

Guest
#11
Hi, Mike,

Your screenshot is kind of interesting.
How did you manage to snapshot the whole scrolling screen?
Do you use a special software?

To find out the root cause of this issue, I would suggest you to not load apache config first, and test to see whether things work as expected.
If it is then definitely there is something in apache conf file preventing you doing this, depending on your context.
E.g., you can check whether RewriteOptions are set to inherit. Google it and you will find much info.

The key to solve any problem is to understand the full picture and isolate the problem step by step.
 
#14
@Pong @NiteWave @Long
After hours of debugging, I found the cause.
It seems to be a bug in Litespeed Enterprise server.

To reproduce the issue:
add these lines to your .htaccess in the main dir (ie. http://website/)
Code:
<FilesMatch "\.(php)$">
deny from 207.14.19.21
</FilesMatch>
Then open up phpinfo in you sub-dir (ie. http://website/subdir/). You will see that the sub-directory .htaccess can not override the PHP rules that were set in the .htaccess in the main dir.
By the way, the deny from 207.14.19.21 is just an example, you can put any rules you want instead, the issue is with the <FilesMatch "\.(php)$"> or any other FilesMatch that covers .php files (such as <FilesMatch "\.+$">)

You can even do:
Code:
<FilesMatch "\.(php)$">
order allow,deny
allow from all
</FilesMatch>

And it will cause the same issue.

Could you please check and confirm this bug?
 
Last edited by a moderator:
L

Long

Guest
#15
Yes, it looks like happening this way.
Thanks for finding it out.
I'll check more and figure it out.
Will get back to you later.

Also found out that if you don't put content in the FilesMatch block,
the subdir .htaccess will override the parent dir one.
 
L

Long

Guest
#17
Yes, I am a new guy to the litespeed tech support team :)

I just informed our developer and confirmed about the bug.
Should be fixed in the next build.

Again, thanks for the effort.
 
#18
Welcome aboard and good luck, Long.
Thanks for your assistance, looking forward to get your fixed build, please update this thread once it is ready so that I will update right away.
 
Status
Not open for further replies.
Top