[thelist] mod_rewrite regex help

Matt Warden mwarden at gmail.com
Mon Dec 20 20:20:55 CST 2004


Joshua,


On Mon, 20 Dec 2004 21:08:57 -0500, Joshua Olson <joshua at waetech.com> wrote:
> > -----Original Message-----
> > From: Matt Warden
> > Sent: Monday, December 20, 2004 8:13 PM
> >
> > Hello list,
> >
> > I have the following rules in my .htaccess file:
> >
> > RewriteEngine On
> > RewriteRule ^/collab.*$ $1 [NC,L]
> > RewriteRule \.(php|htm|html)$ /server.php?q=$1 [NC,L]
> > RewriteRule ^[^\.]*$ /server.php?q=$1 [L]
> 
> > But, my main question has to do with th is just not working at all. I
> > tested my regex's and they seem to match correctly, but I am getting
> > 500 errors in the apache logs when I test things. For example:
> 
> Matt,
> 
> In the example above, it doesn't appear that you've indicated in the rules
> exactly what $1 is going to be.  You accidentally defined in in #2 when you
> added to OR clause.  I would start be changing the rules for 1 and 3 thusly:

Ah, yes. Ok, that makes sense. I have changed it to:

RewriteRule ^(/collab.*)$ $1 [NC,L]
RewriteRule ^(.*\.(php|htm|html))$ /server.php?q=$1 [NC,L]
RewriteRule ^([^\.]*)$ /server.php?q=$1 [L]

But I am still getting 500 errors.
> That may solve your immediate need.  But, I'd warn you that your regex for
> #1 is not fool proof... for example, the following string would match #1:
...
> For #3. you stated that you goal was to "match requests for the default page
> of the root and other directories."  Presuming that folder names are not
> allowed to have .'s in them, then you have likely accomplished what you set
> out to do.

Right. I'm aware of these. I'm just trying to get the basics working
at the moment. Then I can refine things.


Thanks a lot,


-- 
Matt Warden
Miami University
Oxford, OH
http://mattwarden.com


This email proudly and graciously contributes to entropy.


More information about the thelist mailing list