Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-14 04:23:44

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Restrict textpattern from processing specific subfolder

I would like to add a subfolder to my html folder for admin type docs. These will be regular HTML so I do not want textpattern to touch them. It seems it does though… all subfolders get processed through PHP.

Any hints?

I will also post a question on the other way of doing this.


robin

Offline

#2 2007-12-14 05:40:08

jm
Plugin Author
From: Missoula, MT
Registered: 2005-11-27
Posts: 1,746
Website

Re: Restrict textpattern from processing specific subfolder

Create a .htaccess file in the subdirectory with the following:

RewriteEngine Off

Offline

#3 2007-12-14 10:27:32

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: Restrict textpattern from processing specific subfolder

jm: Strangely that does not work. If I directly type in an URL in the subdirectory I get a 404 message from textpattern itself, indicating it is still handling it.


robin

Offline

#4 2007-12-14 10:33:48

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: Restrict textpattern from processing specific subfolder

My mistake. Some sort of refresh error. It works!

Thank you!


robin

Offline

#5 2007-12-14 17:06:33

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: Restrict textpattern from processing specific subfolder

OK, this is so strange. The files in the subfolder are now definitely not appearing. I have tried on a couple of computers, cleared the cache, etc. Textpattern is trying to render files in the folder despite the rewrite rule.

This is annoying. I have no idea how it showed up ok for a while but no longer.


robin

Offline

#6 2007-12-14 18:58:18

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,091
Website GitHub Mastodon Twitter

Re: Restrict textpattern from processing specific subfolder

Can you post a url or 2?

Last edited by colak (2007-12-14 18:58:34)


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#7 2007-12-14 19:24:18

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: Restrict textpattern from processing specific subfolder

I have narrowed the problem. If I have just this in .htaccess then all is ok:
RewriteEngine Off

But I also need to restrict access, so added:
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /yyyyyy/xxxxxx/.htpasswd
AuthGroupFile /dev/null
require valid-user

This does not work. Textpattern grabs the page somehow and I never see a login prompt.


robin

Offline

#8 2007-12-21 14:32:41

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: Restrict textpattern from processing specific subfolder

read the faq

or if it doesn’t work, you can try this

Last edited by iblastoff (2007-12-21 15:07:21)

Offline

#9 2007-12-21 14:59:18

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: Restrict textpattern from processing specific subfolder

iblastoff wrote:

read the faq

Thanks. For some reason missed that when checking the FAQ.

Have gone to the alternate method that allows Help pages to be written like any other article in their own section.


robin

Offline

#10 2007-12-25 15:26:58

boblet
Member
Registered: 2005-08-08
Posts: 53

Re: Restrict textpattern from processing specific subfolder

Although it seems like you’re sorted, I thought I’d post a little about the .htaccess file for anyone interested.

Here’s the default TextPattern .htaccess with some descriptive notes on what each rule does:

# uncomment DirectoryIndex if you have an index.html file being loaded instead of TxP's index.php file
#DirectoryIndex index.php index.html
# uncomment FollowSymLinks to allow Apache to follow aliases, for MultiViews etc
#Options +FollowSymLinks
# uncomment -Indexes to prevent Apache from providing directory listings
#Options -Indexes
# check that mod_rewrite is available
<IfModule mod_rewrite.c>
# turn on rewrite engine
	RewriteEngine On
# if installing in a subdirectory, add the path from your web root (public html folder)
	#RewriteBase /relative/web/path/
# if the requested url is an existing file OR
	RewriteCond %{REQUEST_FILENAME} -f [OR]
# if the requested url is an existing directory
	RewriteCond %{REQUEST_FILENAME} -d
# treat the request as is, make available for other directives (Alias etc), but don't process using following RewriteRules
	RewriteRule ^(.+) - [PT,L]
# anything else forward to TextPattern's index.php
	RewriteRule ^(.*) index.php
</IfModule>
# uncomment to make sure PHP is not using register_globals by default (changed in PHP 4.2)
#php_value register_globals 0

You shouldn’t need to alter the default .htaccess (ie uncomment the four commented lines etc) in most cases, however…

To exclude a subdirectory from being processed by TextPattern (eg for using MultiViews to do content negotiation) you can add an excluding RewriteCond (where folder_name is the subdirectory you want to exclude) to the second RewriteRule (which does send things to TextPattern’s index.php):

# exclude anything starting with folder_name, regardless of case
RewriteCond %{REQUEST_FILENAME} !^folder_name.*$ [NC]
RewriteRule ^(.*) index.php

Or add an including RewriteCond to the first RewriteRule (which doesn’t send things to TextPattern’s index.php):

# include anything that starts with folder_name, regardless of case
RewriteCond %{REQUEST_FILENAME} ^folder_name.*$ [NC]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ - [PT,L]

Find out more about this stuff from Apache’s mod_rewrite documentation or the Perishable Press stupid .htaccess tricks article.

Hope that helps someone :-)

peace – boblet

Offline

#11 2007-12-26 00:33:34

robin746
Member
From: Ireland
Registered: 2007-09-22
Posts: 113
Website

Re: Restrict textpattern from processing specific subfolder

Now that should be a FAQ. Great work.


robin

Offline

#12 2007-12-26 06:39:14

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Restrict textpattern from processing specific subfolder

boblet

Shouldn’t your second example read…

# include anything that starts with folder_name, regardless of case
RewriteCond %{REQUEST_FILENAME} ^folder_name.*$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+)$ - [PT,L]

?? (Note the OR in the flags.)

Also, I think your addition will not only match a folder starting with folder_name but (the following examples assume ^list.*$ as the new RewriteCond) …

  1. any folder starting with folder_name (ie /list/ , /list-public/ , /list-private/ , /listen/ etc.) and…
  2. any file starting with folder_name (ie list.php etc) and…
  3. any file or sub-folder of any folder starting with the folder_name (ie /listening/*.* , /list/private , /list/delete.php etc

That’s a potential security risk. You might want to be much more specific about matching a directory (by including the path markers) and getting rid of the wildcard.

Last edited by net-carver (2007-12-26 15:28:28)


Steve

Offline

Board footer

Powered by FluxBB