Page 1 of 1

htaccess problem

Posted: Tue Feb 20, 2007 9:37 pm
by AngTalunin
I'm using cms-ms with nice mod_rewrite rules, but I want to exclude one directory from being rewritten.

My current htaccess files looks like this:

Code: Select all

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

# 301 Redirect all requests that don't contain a dot or trailing slash to
# include a trailing slash
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule ^(.*) %{REQUEST_URI}/ [R=301,L]

# Rewrites urls in the form of /parent/child/
# but only rewrites if the requested URL is not a file or directory
#RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteCond %{REQUEST_FILENAME} !-d [NC]
RewriteRule ^(.+)$ index.php?page=$1 [QSA]
I have directory named 'beheer' and www.website.com/beheer/ should just go to that directory.
I thougth this rule prevents it from being rewritten:

Code: Select all

RewriteCond %{REQUEST_FILENAME} !-d [NC]
, but that ain't working.

Searching over the internet I found the following rule that could help:

Code: Select all

RewriteCond %{REQUEST_URI} !/beheer/(.*)$ 
RewriteRule ^.*$ - [L]
but this also didn't help.

I have no clues left to solve this...can anyone help?

Re: htaccess problem

Posted: Fri Feb 23, 2007 6:47 am
by kermit
i installed phpodp into a subdirectory of a cmsms 1.04 installation, and it was accessible just fine without having to modify the default .htaccess file.

from ted's explanation in irc, rewrite rules won't apply IF the requested page (not part of cmsms) exists.

i just confirmed this by adding a subdirectory ./test/ to a cmsms104 installation (which is in the domain root, mod_rewrite assumed with hierarchy enabled, and page extension of "/"), placing test files in that subdirectory, and then accessing the subdirectory and each file in it via a web browser.

http://www.domain.com  (root cmsms url)

http://www.domain.com/test/
http://www.domain.com/test/index.html
http://www.domain.com/test/index.php
http://www.domain.com/test/test.html
http://www.domain.com/test/test.php

all load fine, with no interference from cmsms or the rewrite rules in the default .htaccess. even trying to load up http://www.domain.com/test/index.php?page=somepage (the un-rewritten cmsms url format) displayed the test page (regardless of whether 'somepage' was an existing cmsms page alias or not).

the only unexpected behavior was that:

http://www.domain.com/test

displayed the default index page (index.html) properly, but the browser was redirected to:

http://domain.com/test/

but that may be an apache configuration that did that.  (further tests using cmsms installs that are located in the root of a subdomain other than "www" work fine).

the other thing to note is that

http://www.domain.com/test/this-page-doesnt-exist

brings up the cmsms custom 404 page, when enabled. turning that off brings up the server-generated 404 page.

my little testing session also showed that

http://www.domain.com/test.html
http://www.domain.com/test.php

also loaded without problem.

Re: htaccess problem

Posted: Fri Feb 23, 2007 2:47 pm
by Pierre M.
The CMSms specific rules should be at the bottom of the rules. As kermit and you say, the rewrite condition on the directory should do it alone.
AngTalunin wrote: ...Searching over the internet I found the following rule that could help:

Code: Select all

RewriteCond %{REQUEST_URI} !/beheer/(.*)$ 
RewriteRule ^.*$ - [L]
but this also didn't help.
Strange. It is before CMSms specific rules, isn't it ?
Pierre M.