Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2016-02-13 12:52:44
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
.htaccess problem with supposed recursive rules
Suddenly one of my websites no longer worked. I found out that there was a problem with the .htaccess file, but I could not find out the reason.
The hosting supporter wrote me, there was a recursive rules in the following lines:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
He changed the same lines to:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php [L]
Thereafter the site was working again.
It’s strange that the same website previously had worked with the first rules example, that this rules are from the default Textpattern .htaccess file and that all my other sites also works with this first rule set.
Does anyone have an opinion?
Offline
Re: .htaccess problem with supposed recursive rules
It would be interesting to know which of the two changes he made solved the problem.
Both rewrite rules have the PT (pass through) flags set. The first explicitly, the second implicitly. The recursive behaviour is caused by a combination of the rules in this .htaccess file with the rewrite rules set elsewhere, which is why it’s not causing problems in all setups.
Offline
#3 2016-02-14 04:23:37
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: .htaccess problem with supposed recursive rules
If I remove from the first rule example (default .htaccess file) RewriteRule ^(.+) - [PT,L]
the PT flag, this means I let only the L flag, RewriteRule ^(.+) - [L]
, so the access to the site works. The second L flag in RewriteRule ^(.*) index.php [L]
isn’t necessary.
Offline
Re: .htaccess problem with supposed recursive rules
Something I found, that might be interesting to use if you have Apache 2.2.16 or higher installed (most webhosts do). You can replace:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
with:
FallbackResource /index.php
This does assume TXP is installed in the root directory of the website, otherwise you’d have to modify the path to index to match the real location (add the subdirectory to the path).
You would have to supply a favicon.ico yourself to avoid TXP handling requests for those files.
Which makes me think: why doesn’t TXP supply a default favicon? Free advertising!
Offline
#5 2016-02-14 13:47:25
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: .htaccess problem with supposed recursive rules
I don’t find out the Apache version, phpinfo shows:
System Linux cp17.sp-server.net 3.10.0-329.7.2.lve1.4.2.el7.x86_64 #1 SMP Wed Jan 20 10:51:51 EST 2016 ×86_64
Build Date Feb 10 2016 16:55:30
I tried to replace the five lines with FallbackResource /index.php
. The “answer”:
Resource Limit Is Reached
The website is temporarily unable to service your request as it exceeded resource limit. Please try again later.
My original doubts was why the lines in the Textpattern default .httacces file stopped working on February 10 (Build Date Feb 10 2016 16:55:30). I’m waiting also a response from the hosting support.
Offline
Re: .htaccess problem with supposed recursive rules
Thanks ruud i had the problem this week with an erro 500 and your suggestion has worked!
Offline
#7 2016-02-14 14:25:21
- GugUser
- Member
- From: Quito (Ecuador)
- Registered: 2007-12-16
- Posts: 1,473
Re: .htaccess problem with supposed recursive rules
GugUser wrote #297857:
My original doubts was why the lines in the Textpattern default .httacces file stopped working on February 10 (Build Date Feb 10 2016 16:55:30). I’m waiting also a response from the hosting support.
Or there are reasons to change the Textpattern default .httacces file in the future?
Offline
Re: .htaccess problem with supposed recursive rules
The .htaccess file has changed over the years. Mostly additional stuff. But those 5 lines have remained more or less the same since 2005, so I don’t really expect them to change. Adding fallbackresource for those without mod_rewrite activated might be a nice addition, so clean urls work for those setups as well.
Changing [PT,L]
to [L]
rarely has negative side-effects. I can’t think of any.
Offline
Re: .htaccess problem with supposed recursive rules
ruud wrote #297852:
Something I found, that might be interesting to use if you have Apache 2.2.16
interesting… it returns a 500 on 2.2.15
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: .htaccess problem with supposed recursive rules
Offline
Re: .htaccess problem with supposed recursive rules
I had this problem too and spent all afternoon on it — intermittently. This worked. Thanks. My support guy at the host server was not helpful.
My published books on Lulu: http://lulu.com/spotlight/forerunner
Offline