Help with mod_rewrite

software development

#1

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.


#2

Please don’t double post.


Simon Jessey
Keystone Websites | si-blog


#3

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


#4

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]

If you want useful replies, ask smart questions.


#5

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!


#6

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).


If you want useful replies, ask smart questions.