Apache Server configuration support - mod_rewrite headache

This is Interesting: Free IT Magazines  
Home > Archive > Apache Server configuration support > November 2004 > mod_rewrite headache





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 mod_rewrite headache
Phil Thompson

2004-11-20, 8:13 am

hello

I'm trying to get my URL www.com/music/foo/bar/ to map to this query string
www.com/music/index.php?query1=foo&query2=bar (for bar to exist then so must
foo but foo can exist without bar www.com/foo/bar/ is good as is
www.com/foo/ but www.com/bar/ isn't what i want).

Everything I've tried in mod_rewrite has failed so far just giving me 404
erros and sometimes 500 errors depending on the .htaccess code.

Current code I'm using

RewriteEngine On
RewriteBase /music/
RewriteRule ^/(.*)/(.*)/$ index.php%3fartist=$1&album=$2

but I have also tried numerous solutions using different quantifiers and
other such things like ([0-9]{0,3}) or ([_0-9,a-z]) etc butnothing seems
to work.

Please help


--
Phil Thompson
http://www.doubleonegative.com/




Michael Fuhr

2004-11-20, 5:49 pm

"Phil Thompson" <philSPAM@doublonegative.com> writes:

> I'm trying to get my URL www.com/music/foo/bar/ to map to this query string
> www.com/music/index.php?query1=foo&query2=bar (for bar to exist then so must
> foo but foo can exist without bar www.com/foo/bar/ is good as is
> www.com/foo/ but www.com/bar/ isn't what i want).
>
> Everything I've tried in mod_rewrite has failed so far just giving me 404
> erros and sometimes 500 errors depending on the .htaccess code.
>
> Current code I'm using
>
> RewriteEngine On
> RewriteBase /music/
> RewriteRule ^/(.*)/(.*)/$ index.php%3fartist=$1&album=$2


Debugging tip: use RewriteLog and RewriteLogLevel to watch what
mod_rewrite is doing; RewriteLogLevel 3 or greater should show
enough detail. Look closely at lines that say "applying pattern"
and "rewrite".

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Phil Thompson

2004-11-22, 7:50 am


"Michael Fuhr" <mfuhr@fuhr.org> wrote in message
news:4198d18d$1_1@omega.dimensional.com...
> "Phil Thompson" <philSPAM@doublonegative.com> writes:
>
[vbcol=seagreen]
> More debugging tips:
>
> * Read the documentation for directives to see how to use them
> and where Apache allows them.
>
> http://httpd.apache.org/docs-project/


<snip />

okay I think I've got it down now. My server wsn't liking the following; the
first /, the %3f (instead of an ?) and the use of the escpaed ampersand!

so my code is now

RewriteEngine On
RewriteRule ^(.*)/(.*)/$ index.php?foo=$1&bar=$2
RewriteRule ^(.*)/$ index.php?foo=$1

Thanks for your inoput Michael.


--
Phil Thompson
http://www.doubleonegative.com/



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com