rewrite rule query string replacement & subfolder problems

rewrite rule query string replacement & subfolder problems

am 27.07.2007 04:09:55 von Paul Furman

What I want to do is instead of the internal url:
localhost/gallery/california?PG=1&PIC=2
use this kind of url:
localhost/gallery/california/pg1pc2


I'm working with a consultant, here's some instant message discussion
that explains it:


consultant:
in your local apache configuration file, add the following:
RewriteEngine On
RewriteRule ^(.*)pc([0-9]+)$ $1?PIC=$2 [NC,QSA]
RewriteRule ^(.*)/?pg([0-9]+)$ $1?PG=$2 [NC,QSA]

works like a charm
doesn't work at all in .htaccess files because of some helpful behavior
by Apache

me:
I thought htaccess should overwrite config settings?

consultant:
it does. the problem is that .htaccess files are designed to be
per-directory settings, this would work great if you had a real
directory structure and .htaccess files all over those directories
but it doesn't work in the top-level .htaccess because Apache always
adds the subdirectory back to the request
for example: localhost/gallery/california/pg1pc2
gets changed to localhost/gallery/california/pg1pc2?PIC=2
and of course, the second rule won't match

--
Paul Furman Photography
http://www.edgehill.net/1
Bay Natives Nursery
http://www.baynatives.com

nevermind

am 27.07.2007 05:48:44 von Paul Furman

nevermind... my bad... solved...