PDA

View Full Version : mod_rewrite(?) question


l0rdphi1
02-28-2004, 07:39 PM
I know this isn't directly DA related, but I was wondering if anyone knows how to easily rewrite URLs so that when I call www.domain.com/cmd=bah&... it will rewrite as www.domain.com/index.php?cmd=bah&.... This of course will be complete hidden to any browser; any browser should see the former format.

Thanks ;)

l0rdphi1
02-28-2004, 08:10 PM
Well, that wasn't too hard (ha-ha).

This works:RewriteEngine on
RewriteRule (.+) /index.php?$1 [L]Cheers, Phi1.

l0rdphi1
02-28-2004, 10:12 PM
Okay, new problem. This one's a lot more complicated. :(

Need to take a URL as www.domain.com/text?var=val&... and rewrite it as www.domain.com/index.php?one=text&var=val&....

Should work for all of www.domain.com/whatever, www.domain.com/meh? and, of course, www.domain.com/bees?param=value.

I've googled this one to death with absoutely no luck whatsoever. Help, please! Thanks ;)

ProWebUK
02-29-2004, 04:23 AM
Try (not tested):


RewriteEngine on
RewriteRule /text/?var=(*)/(*)/(*$) /newpage.php?var=$1&var2=$2&var3=$3


Basically that should be (colours to understand what goes where)

/text/?var=(*)/(*)/(*$)

redirects to:

/newpage.php?var=$1&var2=$2&var3=$3

Chris

l0rdphi1
03-02-2004, 02:53 PM
This ended up being what I was after:RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)$ /index.php?act=$1&%{QUERY_STRING}Thanks anyways :)