htaccess problem

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
AngTalunin

htaccess problem

Post 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?
User avatar
kermit
Power Poster
Power Poster
Posts: 693
Joined: Thu Jan 26, 2006 11:46 am

Re: htaccess problem

Post 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.
Last edited by kermit on Fri Feb 23, 2007 6:49 am, edited 1 time in total.
eternity (n); 1. infinite time, 2. a seemingly long or endless time, 3. the length of time it takes a frozen pizza to cook when you're starving.
4,930,000,000 (n); 1. a very large number, 2. the approximate world population in 1986 when Microsoft Corp issued its IPO. 3. Microsoft's net profit (USD) for the quarter (3 months) ending 31 March 2007.
CMSMS migration and setup services | Hosting with CMSMS installed and ready to go | PM me for Info
Pierre M.

Re: htaccess problem

Post 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.
Locked

Return to “CMSMS Core”