Mod Rewrite help

Hi people

Having a sticky time with a simple mod rewrite, should be easy but I just cant seem to get it to work tonight.

My incoming URL will look like

[www.mysite.com/pagename/optionname](http://www.mysite.com/pagename/optionname)

I want it to rewrite into

[www.mysite.com/index.php?slug=pagename/optionname/](http://www.mysite.com/index.php?slug=pagename/optionname/)


ie the whole query is to passed as the value of ‘slug’ including any and all backslashes

Ive tried


RewriteEngine on
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^/(.*)$ index.php?slug=$1

and variants to no avail

TIA

Mandes,

Too much wrong for me to correct now - look at the tutorial in my signature and I’ll get back shortly.

Regards,

DK

Okay, how is pagename defined? You’ve got to specify that without being able to conflict with actual (existing) pagenames.

Then, why kill an existing query string?

Then, ^/ will only work on Apache 1.x servers, not on Apache 2.x servers. That’s been the case for several years now.

Finally, what do you expect (.*) to match? It will match EVERYTHING (or NOTHING) and that’s absolutely ridiculous code to use. It’s so bad that I have created a Standard Rant to use:

[rant #1][indent]The use of “lazy regex,” specifically the :kaioken: EVERYTHING :kaioken: atom, (.*), and its close relatives, is the NUMBER ONE coding error of newbies BECAUSE it is “greedy.” Unless you provide an “exit” from your redirection, you will ALWAYS end up in a loop![/indent][/rant #1]

Again, have a look at the tutorial and you’ll learn how to do it correctly. Many have already.

Regards,

DK