PDA

View Full Version : FilesMatch & php .htaccess options


priestjim
05-25-2009, 06:12 AM
Hi!

We are experiencing an issue with the FilesMatch directive and the php_* htaccess options.

A client of ours is using BBClone to monitor his stats but after we switched to LS, the statistics parsing method stopped working. I've pinpointed the error to the .htaccess file he uses:

AddType application/x-httpd-php4 htm html
<FilesMatch "index.htm">
php_value auto_append_file "/var/www/vhosts/xxx/httpdocs/count.php"
</FilesMatch>

If I remove the FilesMatch directive, everything works fine, but with it on, the count.php file does not get appended!

Any help would be appreciated.

mistwang
05-25-2009, 08:55 PM
php_value inside <FilesMatch> was ignored.
You can download and try the latest 4.0.4 build, it should work now.

priestjim
05-25-2009, 11:44 PM
Is it generally working now with directives like "FilesMatch", "Files" and "DirectoryMatch" and options php_flag, php_value, php_admin_flag, php_admin_value, or just FilesMatch and php_value?

Anyway, thanks for the quick response and fix!

DraCoola
05-27-2009, 12:39 PM
Thank you for thread starter.
I am also have a question regarding to .htaccess

Cpanel always create rewrite rules just like this :
-----------------------------------------------
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^.?$ "http\:\/\/domain\.com\/folder" [R=302,L]
-----------------------------------------------

That default Cpanel rules are often (always) makes browser bring Redirect loop error reports with LSWS.




So I have to always manually edit/simply modify that rules to :
-----------------------------------------------
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.domain.com$
RewriteRule ^/?$ "http\:\/\/domain\.com\/folder" [R=302,L]
-----------------------------------------------

That will work fine with LSWS.

So the question is :
How to make LSWS automatically work with default Cpanel redirect rules?
Because it is so wasting time to manualy edit so many .htaccess, which suppose to be just worked at a time after created from Cpanel.

Thank you.

mistwang
05-27-2009, 02:01 PM
How do you make cPanel create rule like that?

The default rule does not look right, as it redirects request with "domain.com" to http://domain.com/, so it causes loop redirections.
I don't know why Apache does not cause loop redirection with it.
We need to investigate.

DraCoola
05-27-2009, 02:17 PM
I don't know how, but Cpanel is always create rules just like that when creating redirect from Cpanel's redirect menu.

The situation is the same way either with old or new hosting account.
Redirect domain/subdomain/folder to another url will causing redirect loop.

So everytime after setuping redirect from Cpanel's menu, I have to replace "." with "/" by my self.

Any clue?
Or I have to PM my temporary root detail to you so you could investigate this?

DraCoola
05-27-2009, 07:13 PM
Ramdomly redirect loop victim --> http://audiogazmo.com

Even mysql.allow persistent turned Off on php ini.

The .htaccess :
-----------------------------------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
-----------------------------------------------


The error log from Cpanel :
-----------------------------------------------
2009-05-28 08:58:44.888 [INFO] [HTAccess] Updating configuration from [/home1/audiocom/public_html/.htaccess]
2009-05-28 08:52:28.582 [INFO] [HTAccess] Updating configuration from [/home1/audiocom/public_html/.htaccess]
2009-05-28 08:50:40.281 [INFO] [HTAccess] Updating configuration from [/home1/audiocom/public_html/.htaccess]
-----------------------------------------------


Everyday, twice or more, any of my customers report that their websites cannot open because of Redirect Loop.
I'm so tired with this many ways of Redirect Loop problems...

Tony
05-27-2009, 09:46 PM
With wordpress the cause is far more likely in wordpress they have it set to www.audiogazmo.com and the htaccess to audiogazmo.com then you create a loop.

Maybe not in this case but a lot of the time thats the issue with wordpress.

mistwang
05-27-2009, 10:33 PM
So everytime after setuping redirect from Cpanel's menu, I have to replace "." with "/" by my self.

Do you mean "Redirects" function in the "domains" section? Or something else?

DraCoola
05-28-2009, 12:59 PM
Do you mean "Redirects" function in the "domains" section? Or something else?
Yes, I mean creating redirects from "Redirects" function in the "domains" section

http://img154.imageshack.us/img154/9726/redirectm.jpg

mistwang
05-28-2009, 05:31 PM
Please download updated 4.0.4 release package.
Add code to detect loop redirections.

DraCoola
05-28-2009, 06:42 PM
I already using 4.0.4 before.
All right then I will download and run upgrade again.

DraCoola
05-29-2009, 03:35 AM
Definitely not help much...
Another victim ---> http://slabgames.com

Everyday, 1-4 per day, I am facing this report from my Redirect Loop customers :(

mistwang
05-29-2009, 06:16 AM
I need the whole .htaccess file and what you have to change to fix it. the URL that caused loop redirection.

DraCoola
05-29-2009, 09:03 AM
The newest victim, reported just few minutes ago ---> http://mp3smackers.com

And here is the whole .htaccess entry :
---------------------------------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
---------------------------------------------

I didn't change anything to fix that. Just confuse, give up, and waiting for your solution http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/9.gif

The only simple fix I did is just for the default redirect rule from Cpanel.
---> http://www.litespeedtech.com/support/forum/showpost.php?p=15371&postcount=4

DraCoola
05-29-2009, 09:19 AM
Update :

Replaced with Apache, and then went back to LSWS = cured!

:confused:

DraCoola
05-29-2009, 09:23 AM
Update v0.2 :

While testing from another server :

LSWS
http://www.dracoola.org/bench_2.jpg


APACHE
http://www.dracoola.org/bench_3.jpg

mistwang
05-29-2009, 01:10 PM
The newest victim, reported just few minutes ago ---> http://mp3smackers.com

And here is the whole .htaccess entry :
---------------------------------------------
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
---------------------------------------------

I didn't change anything to fix that. Just confuse, give up, and waiting for your solution http://l.yimg.com/us.yimg.com/i/mesg/emoticons7/9.gif

The only simple fix I did is just for the default redirect rule from Cpanel.
---> http://www.litespeedtech.com/support/forum/showpost.php?p=15371&postcount=4

It does not make much sense with the information you provided, if that's the whole .htaccess file, how could you fix the redirect rule causing problem if those rules does not even in the .htaccess? :confused:

I need the exact and complete .htaccess file that causing loop redirections.

mistwang
05-29-2009, 01:12 PM
What have you done between update and update v0.2 to make it comes back?

DraCoola
05-29-2009, 02:00 PM
It does not make much sense with the information you provided, if that's the whole .htaccess file, how could you fix the redirect rule causing problem if those rules does not even in the .htaccess? :confused:

I need the exact and complete .htaccess file that causing loop redirections.
I thought, if from wordpress case, it doesn't caused by .httaccess.
As my screen shoots for LSWS and Apache at above, there is "301 moved permanently" that have been makes page redirected in loop.

I'm Also not doing fixing for anything for that wordpress cases.
Because I have just replacing each other between apache and LSWS, and then it magically fixed.
But actually... that's not the permanent fixed.
Because if it accessed from command line : "HEAD mp3smackers.com", there are still shows for redirect loop.

So I guest the "finally fixed shown on browser" cames from cache after using Apache temporarily before it went back to LSWS?

DraCoola
05-29-2009, 02:07 PM
What have you done between update and update v0.2 to make it comes back?
I'm doing nothing, George.
Except just switching between LSWS and Apache in purpose to test accesing mp3smackers.com from another server.

It is so unpermanent. Random attend.

mistwang
05-29-2009, 03:41 PM
I thought, if from wordpress case, it doesn't caused by .httaccess.
Then, you should not mix them together, it only make it harder to identify the cause of the problem.


As my screen shoots for LSWS and Apache at above, there is "301 moved permanently" that have been makes page redirected in loop.

I'm Also not doing fixing for anything for that wordpress cases.
Because I have just replacing each other between apache and LSWS, and then it magically fixed.
The screen shot shows that the redirect is actually sent by PHP, LSWS is just the messenger.


Because if it accessed from command line : "HEAD mp3smackers.com", there are still shows for redirect loop.
What the actually command of "HEAD"? I think it is just a command alias.
I tried "curl -I mp3smackers.com", it works fine.
"lynx -head -mime_header http://www.mp3smackers.com" also works.


So I guest the "finally fixed shown on browser" cames from cache after using Apache temporarily before it went back to LSWS?
Not sure, as my firefox never has problem with this site from beginning.
Which browser you used?

X-Nitro
05-29-2009, 11:21 PM
Let me introduce my self, I'm X-Nitro 2nd Administrator of DraCoola Multimedia. This bugs only occured on Wordpress Instalation. For example, like some pictures below :

!= Wordpress :
$ curl -I dracoola.com
http://www.dracoola.org/curl_dracoola.jpg

MyBB Bulletin Board
$ curl -I kikil.org
http://www.dracoola.org/curl_kikil.jpg

Now, I will try get header information from some victims (checked at 08:13 GMT+7)
http://www.dracoola.org/bench_4.jpg

And then, I'll try to get header information again from some victims above.
http://www.dracoola.org/bench_5.jpg

Automatic Cured, huh ? o_O


Now, other victims appeared.
http://idwz.net
http://moviedb.asia
http://www.dracoola.org/bench_6.jpg

Complete .htaccess for idwz.net (Permalinks: /downloads/%postname%.aspx) :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Complete .htaccess for moviedb.asia (Permalinks: /%postname%.aspx/?%post_id%.download) :

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


I'm desperate. :(

X-Nitro
05-30-2009, 01:53 AM
Update :

Checked @ 15:53 GMT +7
http://www.dracoola.org/bench_7.jpg

I do nothing.

DraCoola
05-30-2009, 02:03 AM
Then, you should not mix them together, it only make it harder to identify the cause of the problem.
Pardon me for double issue reporting on this thread.
It perhaps better to split my wordpress issue to another thread, so it can still focused per issue per thread by anyone.

auser
05-30-2009, 02:32 AM
Accessing
http://idwz.net
http://moviedb.asia

there is no problem(infinite loop). Already resolved without any change?

with following rewrite rule only:

Complete .htaccess for idwz.net (Permalinks: /downloads/%postname%.aspx) :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress


I tested latest lsws 4.0.4(standard version) and apache 2.2.11
None will cause infinite redirect loop.

Are there any other possible rewrite rules applied?
I noticed:
http://idwz.net/a
http://idwz.net/b
i.e., a single letter following http://idwz.net/ will redirect to other page;
while 2 letters etc will go "Not Found"
http://idwz.net/aa -- Not Found
http://idwz.net/bb -- Not Found

maybe this is a wordpress module, and has conflict with the .htaccess?
Just a guess.

X-Nitro
05-30-2009, 03:22 AM
@auser,
yup, already solved without any changes :) I've try disable all module, but useless.
Notes :
This errors only occured at wordpress instalation.

auser
05-30-2009, 03:46 AM
@auser,
yup, already solved without any changes

just to confirm: so now works well? or problem still occur randomly?

mistwang
05-30-2009, 07:47 AM
Have you enabled disk cache? If yes, you should disable it for now.
I think it caches response for request http://www.mp3smackers.com/, which redirects to http://mp3smackers.com/

X-Nitro
05-30-2009, 08:31 AM
just to confirm: so now works well? or problem still occur randomly?
so far no problem :)

DraCoola
05-30-2009, 12:17 PM
Newest victim ---> http://resureksi.com

Wordpress inside, opening with firefox.

X-Nitro
05-30-2009, 12:45 PM
Newest victim ---> http://resureksi.com

Wordpress inside, opening with firefox.
Screenshot below :
http://www.dracoola.org/resureksi.jpg

Get header from another server :
http://www.dracoola.org/resureksi_check.jpg

Last Checked @ 02:44 GMT +7

mistwang
05-30-2009, 01:38 PM
It is the LSWS disk cache feature, not WP cache plugin, disabled it for now.
The problem that WP redirect www.domain.com to domain.com, if LSWS cache the redirect, it will cause trouble. We have to change the cache code to put requests to www.domain.com and domain.com in two separate cache.

DraCoola
05-30-2009, 02:59 PM
Thank you in advance, George.
I hope (and I am sure) the changed code will be included in the official release of 4.0.4 :)

mistwang
05-30-2009, 04:03 PM
updated 4.0.4 has addressed this. you can give it a try.

mistwang
05-30-2009, 04:04 PM
Please wait for 10 minutes to have the updated version uploaded.

DraCoola
05-30-2009, 04:11 PM
Awesome. I will try it as soon as it available.
So many thanks for your rapid technical support.

mistwang
05-30-2009, 04:26 PM
OK, it has been uploaded.

DraCoola
05-30-2009, 04:39 PM
I'm going to update my LSWS, right now.
You're just so wonderful, George.
Thank you.

DraCoola
05-30-2009, 04:46 PM
Done, updated.
With LSWS cache re-enabled.
And I have empty my cache dir before this.
I hope this can make the sweet change to wordpress + LSWS.

X-Nitro
05-30-2009, 07:23 PM
Nice, works like a charm :D