mod_rewrite(?) question

l0rdphi1

Verified User
Joined
Jun 22, 2003
Messages
1,471
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 ;)
 
Well, that wasn't too hard (ha-ha).

This works:
Code:
RewriteEngine on
RewriteRule (.+) /index.php?$1 [L]
Cheers, Phi1.
 
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 ;)
 
Try (not tested):

Code:
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
 
This ended up being what I was after:
Code:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.\?/]+)$ /index.php?act=$1&%{QUERY_STRING}
Thanks anyways :)
 
Back
Top