Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite .php?a=x&b=x

         

redlined

1:54 am on Jul 23, 2005 (gmt 0)

10+ Year Member



Hi there

I am trying to rewrite my URLs to be more clean and am having problems with mod_rewrite

Currently I have:

index.php?a=cat&b=x
or possibly even
index.php?a=cat&b=x+y+z

There are only 5 categories but there are several hundred terms at the end in place of x, y and z.

I would like the rewrites to be like the following:

domain.com/index.php?a=cat1&b=x to
domain.com/cat1/x

domain.com/index.php?a=cat1&b=x+y+z to
domain.com/cat1/x-y-z

If anyone could help me with the following it would be most appreciated

jdMorgan

2:33 am on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



redlined,

> having problems with mod_rewrite

Please post your code so we can discuss it. Also, take a look at our forum charter [webmasterworld.com] for references and info on this forum. You may want to follow along on this similar thread: [webmasterworld.com...] since we seem to be getting a lot of almost-identical questions today.

Jim

Birdman

2:40 am on Jul 23, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello, welcome to the boards!

You are actually doing it backwards. It's a common misconception. You cannot make the URLs friendly with mod_rewrite alone.

You have to adjust your scripts to print the good URLs, then use mod_rewrite to turn them into useable URLs.

PHP SCRIPT(modify to your server-side language):

echo '<a href="/cat/x"></a>';

.htaccess:

RewriteRule ^/cat/(.*)$ [L]

Note: The example above is very generic.

[added]good call jd, this is now the third post in a row that I was too slow on! can't beat the responsiveness of WW![/added]