What do I need to do to turn dynamic urls into static urls?
#first switch rewriting on
RewriteEngine on
#now rewrite any thing that matches mydomain.com/myscript/scriptparameter.html to mydomain.com/cgi-bin/myscript.cgi?scriptparameters
#rewrite - syntax is rewriterule FROM TO
RewriteRule ^myscript/([0-9a-zA-Z]+).html /cgi-bin/myscript.cgi?$1 [L]
The ([0-9a-zA-Z]+) basically means "match any combination of letters and numbers", whatever is matched is then stored in the variable $1 and used in the real url.
In the above example if someone typed mydomain.com/myscript/blahblah.html the server would actually return mydomain.com/cgi-bin/myscript.cgi?blahblah
Wow now my head hurts :)
but isn't the example backwards? Don't you want to go from
url.com/bla?whatever.htm
to
url.com/bla/whatever.htm
?
-G
The thing to remember is that the real url doesnt change and you are just masking it with a nicer looking one. You are telling mod_Rewrite "when you see the nice url rewrite it to the real url", you are not actually changing the url.
E.g
User types /blah/3 mod rewrites it to /blah.pl?x=3 because /blah.pl?x=3 is the REAL url. In fact the user could still type /blah.pl?x=3 and it would work perfectly.
Hope I make sense :)