Apache rewrite rules redux

Posted by AlexanderJohannesen on Stack Overflow See other posts from Stack Overflow or by AlexanderJohannesen
Published on 2009-04-26T10:35:00Z Indexed on 2010/03/26 2:03 UTC
Read the original article Hit count: 426

Filed under:
|
|

I've got a REST framework that when plopped into any directory should Just Work(TM), and it seems to work fine when I've got projects in subdirectories, but not if it's in root. So, given a few example directories;

/
/project1
/bingo/project2
/hoopla/doopla/minor/project3

All of these works fine, except I'm getting "funnies"* when the project runs in the root directory (bit hard to explain, I suppose, but the second level rewrites are not working properly). Here's my attempt at a generic .htaccess file:

RewriteEngine On
RewriteRule ^static/ - [L]
RewriteCond %{REQUEST_URI} ^$
RewriteRule .* ./ [R,L]
RewriteRule ^index.php - [L]
RewriteRule (.*) index.php?q=$1 [QSA,PT]

(And yes, all projects have a subdirectory ./static which is ignored by rewrites) What I'm trying to achieve is a set of rewrite rules that work for most cases (which is, again, plonking the project in a directory the webserver serves). I'm not a rewrite rules wiz by a long shot, and any good advice and gotchas would be appreciated (and yes, I've gone through too many introductory articles. I need some serious juice.)

  • More info on the funnies; my webserver has docroot in one spot (under /usr/share/apache2/default-site/), but a set of rules that says that /projects is pulled in from somewhere else that's not a subdirectory of docroot (/home/user/Projects/). When I go there, I get a list of /projects subdirectories, and if one of those subdirectories gets called (restmapp) with the proposed rewrite rules, I get ;

    The requested URL /home/user/Projects/restmapp/index.php was not found on this server.

© Stack Overflow or respective owner

Related posts about apache

Related posts about rewrite