Shoutbox

Is anyone farmiliar with mod_rewite? - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Is anyone farmiliar with mod_rewite? (/showthread.php?tid=76173)

Is anyone farmiliar with mod_rewite? by Baggins on 07-18-2007 at 12:22 AM


.htaccess

code:
RewriteEngine on
RewriteRule ^/hosted/([^/\.]+)/?$ http://%{HTTP_HOST}/hosting.php?file=$1 [R]


you can see how it works now by going to http://files.1337z.com/hosted/test.htm

you can see how it is supposed to work by going to http://files.1337z.com/hosting.php?file=test.htm

can anybody spot a problem?

thanks in advance.
RE: Is anyone farmiliar with mod_rewite? by WDZ on 07-18-2007 at 01:13 AM

Try removing the first slash. It won't match in a per-directory context because mod_rewrite automatically strips off the directory prefix for you.

Lots more info at: http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule

Also, if you want "test.htm" to be redirected, you'll need to modify the regexp so dot characters are allowed. :p

code:
RewriteRule ^hosted/([^/]+)/?$ http://%{HTTP_HOST}/hosting.php?file=$1 [R]

RE: Is anyone farmiliar with mod_rewite? by Baggins on 07-18-2007 at 01:37 AM

Thanks for that :>

Works perfect now.