Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#97 2010-07-25 21:14:10
- Deel
- New Member
- Registered: 2010-07-25
- Posts: 1
Re: Post your Clean URL .htaccess tweaks here
Hi guys,
I’ve installed textpattern two times for now, the first time I was stuck with the clean URL thing and I thought, well, this product is great but I’m testing CMSs and I have no time for that. I’ve tested a lot of CMS since this time and I must admit TextPattern is just fantastic. Using this link (Forum), and thanks to the community here, I’ve made a small howto that works on Linux Debian Lenny, here it is, I guess it’ll work on any debian box.
1/ Modifying the default apache site allowing apache to handle .htaccess
Edit /etc/apache2/sites-available/default and look for <Directory /> then change :
AllowOverride none
by
AllowOverride all
2/ Enabling mod_rewrite in Apache2, type this at the console prompt
a2enmod rewrite
/etc/init.d/apache2 reload
That’s all
3/ Make a .htaccess file at the root dir of your installation (for me it’s /var/www)
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
3bis/ If textpattern is not installed at the rootdir but at /var/www/something/
RewriteEngine On
RewriteBase /something/
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteRule ^(.*) index.php
4/ You can find a .htaccess sample clicking ‘?’ in diagnostics=> Preflight check or at the svn
Regards,
Deel
Last edited by Deel (2010-07-26 00:17:49)
Offline
Re: Post your Clean URL .htaccess tweaks here
Hi Deel,
I don’t know about your other points, but re:
I’ve read that a sample “.htaccess” file was provided with textpattern, I’ve never found it…
I think one way to find out what it should be is to have no .htaccess file, then go to ‘Admin, Diagnostics’ (I think, I’m away from proper web access) and you should get a warning about missing .htaccess file, with a ‘?’ link adjacent. That link takes you to a copy of the std .htaccess file.
Luck. Cheers -Alan
At LAST I’ve cheerfully donated to the core devs at #TXP. I only wish I were able to give more. Thanks to the devs and ALL fellow TXPers. -A
Offline
#99 2010-07-25 23:13:27
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: Post your Clean URL .htaccess tweaks here
Deel
3/ I’ve read that a sample “.htaccess” file was provided with textpattern, I’ve never found it…
It’s there alright — I’m assuming from your post that you’ve not got hidden files hidden in whatever tool you’re using to look at the source tree. So, in the meantime, here’s a link to it in the svn repository.
— Steve
Offline
#100 2012-04-04 09:25:18
- SandraN
- New Member
- Registered: 2012-04-04
- Posts: 1
Re: Post your Clean URL .htaccess tweaks here
I tried various things that were posted here for the German “1und1” but nothing worked. Then I found a hint here (http://forum.textpattern.com/viewtopic.php?id=29976) that suggested adding this: Options -MultiViews
.
This is the complete content of my .htaccess now and it works (note: the /textpattern/
is used because I have my installation running in this subdirection):
DirectoryIndex index.php index.html
Options +FollowSymLinks
RewriteBase /textpattern/
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
Options -MultiViews
</IfModule>
#php_value register_globals 0
Offline
#101 2013-09-02 20:05:42
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)
Offline
#102 2014-10-11 16:21:20
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
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,473
Re: Post your Clean URL .htaccess tweaks here
You mean this .htaccess problem with supposed recursive rules.
Offline