Textpattern CMS support forum

You are not logged in. Register | Login | Help

#101 2013-09-02 20:05:42

NicolasGraph
Plugin Author
From: France
Registered: 2008-07-24
Posts: 860
Website

Re: Post your Clean URL .htaccess tweaks here

Working with TXP4.5.4 on 1and1 (fr)

DirectoryIndex index.php index.html

Options +FollowSymLinks
#Options -Indexes
#ErrorDocument 403 default

<IfModule mod_rewrite.c>
	RewriteEngine On
	RewriteBase /

	RewriteCond %{REQUEST_FILENAME} -f [OR]
	RewriteCond %{REQUEST_FILENAME} -d
	RewriteRule ^(.+) - [PT,L]

	RewriteCond %{REQUEST_URI} !=/favicon.ico
	RewriteRule ^(.*) index.php

	RewriteCond %{HTTP:Authorization}  !^$
	RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>

#php_value register_globals 0

# SVG
AddType image/svg+xml  svg svgz
AddEncoding gzip       svgz

Last edited by NicolasGraph (2013-09-02 22:28:07)


Nicolas
Follow me on Twitter and GitHub!
Multiple edits are usually to correct my frenglish…

Offline

#102 2014-10-11 16:21:20

Viktor
Member
From: Nürnberg
Registered: 2008-09-12
Posts: 21
Website

Re: Post your Clean URL .htaccess tweaks here

Just a little note:

If your textpattern installation is stored in a subfolder you need to adjust the

RewriteBase /

according to your path.

Offline

#103 2016-04-02 19:53:27

NNF
Member
Registered: 2006-02-27
Posts: 13

Re: Post your Clean URL .htaccess tweaks here

Just a little heads up: it seems there has been a change in a recent version of Apache that causes the default .htaccess rewrite rules to fail. I wrestled with it for an hour or so and finally settled for this:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php [L]
</IfModule>

Seems to be the only thing that works!

Last edited by NNF (2016-04-02 19:56:14)

Offline

#104 2016-04-02 21:28:20

ruud
Developer emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

Re: Post your Clean URL .htaccess tweaks here

Which Apache version… and how did it fail; did you get an error message (which one)?

Offline

#105 2016-04-02 22:49:15

NNF
Member
Registered: 2006-02-27
Posts: 13

Re: Post your Clean URL .htaccess tweaks here

I am not sure which specific version my host (NearlyFreeSpeech) is using. All I know it’s 2.4 something.

What happened is mod_rewrite would get stuck in an infinite loop (causing a 500 internal server error to the end user):

[Sat Apr 02 19:10:42.191056 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#80742d0a0/initial] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.191496 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#8074181e8/initial/redir#1] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.193195 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#807410628/initial/redir#2] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.194845 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#807411d08/initial/redir#3] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.196724 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#80741a758/initial/redir#4] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.198640 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#807413548/initial/redir#5] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.200848 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#80741c750/initial/redir#6] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.202764 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#807437c50/initial/redir#7] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.204893 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#80743f850/initial/redir#8] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.207316 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#807442400/initial/redir#9] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.209900 2016] [rewrite:trace1] [pid 19220:tid 34479639552] mod_rewrite.c(477): [client 172.17.240.6:60514] 172.17.240.6 - - [www.mywebsite.org/sid#8021e4788][rid#807445a90/initial/redir#10] [perdir /fs6a/mywebsite/public/] internal redirect with /index.php [INTERNAL REDIRECT], referer: http://www.mywebsite.org/index.php?id=334
[Sat Apr 02 19:10:42.214057 2016] [core:error] [pid 19220:tid 34479639552] [client 172.17.240.6:60514] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace., referer: http://www.mywebsite.org/index.php?id=334

And this is what my host told me:

This appears to be related to a change in Apache that made the interpretation of rewrite rules more strict.

It’s debatable / an open question as to whether your rewrite rules were never supposed to work and this change fixed that, or whether the change itself has a bug / is overzealous.

At a guess, it’s sort of the former because it looks like your rules were intended for us in an httpd.conf file rather than an .htaccess file; they do not account for the differences between the two. (However, many people aren’t aware of those differences.)

(Either way, what the Apache developers do is beyond our control and therefore it’s not a system problem.)

I’m inclined to believe them because these guys seem to know their stuff very well, but this is all the information I have right now. I will see if perhaps they can elaborate.

Last edited by NNF (2016-04-02 23:03:22)

Offline

#106 2016-04-03 09:36:34

NNF
Member
Registered: 2006-02-27
Posts: 13

Re: Post your Clean URL .htaccess tweaks here

It seems to affect Apache 2.4.18:

https://bz.apache.org/bugzilla/show_bug.cgi?id=58854#c8

Also, I only just stumbled across the other thread here where someone else was having the same problem. As mentioned there, just removing the [PT] flag from the original rewrite rule fixes the problem, too. Though I’m inclined to keep what I have right now, since it seems to work just as well and it’s shorter and easier to understand (to me, anyway).

Last edited by NNF (2016-04-03 09:36:50)

Offline

#107 2016-04-03 12:25:38

GugUser
Member
From: Quito (Ecuador)
Registered: 2007-12-16
Posts: 1,391

Re: Post your Clean URL .htaccess tweaks here

Offline

Board footer

Powered by FluxBB