Help with mod_rewrite

Help with mod_rewrite

Posted by: dpix
Posted on: 2006-03-02 10:48:00



This is a friendly call for help to anyone familiar with the apache mod_rewrite script.

I've got my Movable Type install on xxx.com and using plugin (tags.app) that handles all tag searches at eg. xxx.com/mt/mt-tags.cgi and of course receives ugly queries in the form of mt-tags.cgi?blog_id=7&tags=$1

I have a blog on the same DH server on a different domain yyy.com and what I'm trying to do is get yyy.com/tag/whatever to rewrite into the xxx.com tag script.

I thought this rewrite would work in an htaccess file placed in the blog's yyy.com root;

RewriteEngine on
RewriteRule ^tag/(.+) /home/.dhserver/servername/xxx.com/mt/mt-tags.cgi?blog_id=7&tags=$1 [QSA,L]

However, it's not working. Can anyone tell me what I'm doing wrong with my syntax or htaccess placement?

Thanks in advance to anyone who can offer up some advice.
Cheers.

Re: Help with mod_rewrite

Posted by: scjessey
Posted on: 2006-03-02 11:24:00

Please don't double post.

Re: Help with mod_rewrite

Posted by: dpix
Posted on: 2006-03-02 11:34:00

Sorry, my bad.
I just realized after the fact that it was a question that belonged in here.

Re: Help with mod_rewrite

Posted by: kchrist
Posted on: 2006-03-02 12:20:00

mod_rewrite URLs are relative to the web site root, not the filesystem root. So the above rule should be written like this:

RewriteEngine on
RewriteRule ^tag/(.+) /mt/mt-tags.cgi?blog_id=7&tags=$1 [QSA,L]

Re: Help with mod_rewrite

Posted by: dpix
Posted on: 2006-03-02 12:30:00

Ok, much thanks for the suggestion.
Quick follow-up question:
Where should the htaccess file be placed?
In the root of the domain folder for the blog or the root of the domain folder for the mt install? Or both?

Thanks again for your help!

Re: Help with mod_rewrite

Posted by: kchrist
Posted on: 2006-03-02 13:17:00

For this rule to work, it should go in the root directory of your site. Compare the URIs in the rule to see why it won't work from a subdirectory (hint: look at the directories, or lack thereof, in the path you're matching).

Tags: modxxxcgimovable typeuglyqueriesapacheblogtag