Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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
Re: Restrict textpattern from processing specific subfolder
Create a .htaccess file in the subdirectory with the following:
RewriteEngine Off
Offline
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
Re: Restrict textpattern from processing specific subfolder
My mistake. Some sort of refresh error. It works!
Thank you!
robin
Offline
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
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
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
Re: Restrict textpattern from processing specific subfolder
Offline
Re: Restrict textpattern from processing specific subfolder
iblastoff wrote:
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
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) …
- any folder starting with
folder_name
(ie /list/ , /list-public/ , /list-private/ , /listen/ etc.) and… - any file starting with
folder_name
(ie list.php etc) and… - 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