Apache Server configuration support - rewrite rule query string replacement & subfolder problems

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > July 2007 > rewrite rule query string replacement & subfolder problems





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author rewrite rule query string replacement & subfolder problems
Paul Furman

2007-07-27, 1:22 am

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
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com