Page 1 of 1

yup, another mod_rewrite question

Posted: Wed Feb 21, 2007 5:16 pm
by Luke
OK I bought both a regex book and a mod_rewrite book and am in the process of reading both, so these questions should start to diminish some time soon, but for now, can somebody explain to me why this simple rule won't work?

Code: Select all

RewriteRule ^/c/([A-Za-z0-9_-]+)$ /merchant2/merchant.mvc?Screen=CTGY&Store_Code=BS&Category_Code=$1 [L,QSA]
If you put in the second half manually into the URL, it works fine. so what am I doing wrong.... (if for example I type in /c/PL)

EDIT: Oh and I'm getting a 404

I just don't get it... this doesn't work either:

Code: Select all

RewriteRule   ^/(|merchant\.mvc|index\.html)?$   /merchant2/merchant.mvc [L,QSA]
What in the world am I doing wrong??

The .htaccess file is in the right directory! :?

Posted: Wed Feb 21, 2007 10:38 pm
by Kieran Huggins

Code: Select all

RewriteRule ^\/c\/([A-Za-z0-9_\-]+)$ /merchant2/merchant.mvc?Screen=CTGY&Store_Code=BS&Category_Code=$1 [L,QSA]
?

Re: yup, another mod_rewrite question

Posted: Wed Feb 21, 2007 11:49 pm
by cinac
can somebody explain to me why this simple rule won't work?

Code: Select all

RewriteRule ^/c/([A-Za-z0-9_-]+)$ /merchant2/merchant.mvc?Screen=CTGY&Store_Code=BS&Category_Code=$1 [L,QSA]
If you put in the second half manually into the URL, it works fine. so what am I doing wrong.... (if for example I type in /c/PL)

EDIT: Oh and I'm getting a 404
Does your web server's error log (i.e., /var/log/httpd/error_log) give any more specifics? A 404 will typically tell you exactly what it's trying to find, and that might lead you to what the problem is...

Also, silly question, but does the /merchant2 directory exist (with web server-readable permissions) at the same "level" as /c ?
this doesn't work either:

Code: Select all

RewriteRule   ^/(|merchant\.mvc|index\.html)?$   /merchant2/merchant.mvc [L,QSA]
No clue on this one. Should that leading pipe symbol be there? Check the error log - that's always the first thing I look at when troubleshooting. Also, if you are using Apache, you can enable separate logging (via the RewriteLog directive) for mod_rewrite so that you can see exactly what it's trying to do each step of the process... See http://httpd.apache.org/docs/1.3/mod/mo ... RewriteLog and http://httpd.apache.org/docs/1.3/mod/mo ... teLogLevel for more info.

Posted: Thu Feb 22, 2007 1:11 am
by Luke
changed to this:

Code: Select all

RewriteRule ^c/([A-Za-z0-9_-]+)$ merchant2/merchant.mvc?Screen=CTGY&Store_Code=BS&Category_Code=$1 [L,QSA]
and now it works fine... :roll:

I'm not sure I understand why. :? shouldn't it have rewritten the request uri to /merchant/ ... blabla ... ?

The other one is the same problem (as well as the leading pipe which I forgot to take out before posting here)