Page 1 of 1

mod_rewrite problem from / to /public_html/

Posted: Sat Feb 03, 2007 12:49 pm
by tecktalkcm0391
I have a .htaccess file in /home/ of my site.... my site's html is in /home/public_html/

Whenever I do a rewrite like
RewriteRule ^img([A-Za-z0-9]+).image/$ img.php?picid=$1 [NC]

It goes from site.com/img4.image/ to site.com/public_html/img4.image

How can I fix this?

Posted: Sat Feb 03, 2007 4:02 pm
by Ollie Saunders
Does rewrite start from $0 or $1? If the latter you might want to try $2.

Posted: Sat Feb 03, 2007 7:20 pm
by feyd
$0 would be the entire match, $1 is the first captured group, $2 is the second and so forth...

Posted: Sat Feb 03, 2007 8:04 pm
by superdezign
I'm not familiar with RewriteRule, but I do some work with servers and it sounds like your host made "public_html" your root... I guess you'd have to forcefully go back a directory if you have permissions to it.

Posted: Mon Feb 05, 2007 7:33 am
by m3mn0n
To fix it simply reference the proper location in the second part of the rule... you simply reference img.php without indicating what folder it's in... so naturally it assumes the working directory which is why it's returning /home/

eg. /home/public_html/img.php

Be sure to also use the flag QSA and if it's the only or last rule, use the flag L.