Question : Rewrite an individual dynamic URL to a static URL (not site-wide)

Hello, I have looked through a bunch of mod_rewrite solutions on EE and haven't come across this specific issue:

I am looking to rewrite an individual dynamic URL to a static URL. That is, I have an existing dynamic URL like:

www.mysite.com/support/article?id=23

and I would like to permanently redirect it to a new static URL location at:

www.mysite.com/new_section/article_title/
(This page realy exists - not just a rewrite)

To be clear, this is being done to permanently redirect a dynamic URL to a static to maintain search ranking on a specific article that has been moved within the site (not a site-wide rewrite). I only have a few dynamic URL's I want to redirect on the site.

The current solution I have that works is this:

RewriteCond %{THE_REQUEST} id=23
RewriteRule . http://www.mysite.com/new_section/article_title? [R=301,L]

This works perfectly, except that I have other sections of the site utilizing the id parameter and they get hijacked by this rewrite condition if they use the same id number from the db. I am guessing I need a way to make that rewrite condition for a specific section of the site. My hope would be to define it like this, although I know this won't work:

RewriteCond %support/article id=23

that way say a Press section article at

www.mysite.com/press/article?id=23

wouldn't be incorrectly redirected to the new static page for the Support section.

To help further clarify, really I would be happy if I could just do this in my htaccess:

Redirect 301 /support/article?id=23 http://www.mysite.com/new_section/article_title

But the dynamic URL doesn't work in this Redirect rule.

Any help would be greatly appreciated.

Thanks

Answer : Rewrite an individual dynamic URL to a static URL (not site-wide)

Which part?  You may not be able to do this if you are using a shared host.  If you find you do not have access to the files I'm talking about, contact your host about turning on the rewrite log.

The main server conf files for apache are (by the RPM I have, anyways) /etc/httpd/conf/httpd.conf, /etc/httpd/conf/httpd.include, and any number of other include files.  If you use a configuration file to create and maintain your on that server, use that file.  In fact, these lines will preferably be placed inside the container.  Absent that ability, any included server conf file will do, but it cannot be .htaccess.  

RewriteLog /path/to/log/file
RewriteLogLevel 9

Note that /path/to/log/file should be replaced by the full path and filename of the log file you want it to use.  To make things simple, I'll use the example of /var/log/rewrite.log.  Those lines should now read:

RewriteLog /var/log/rewrite.log
RewriteLogLevel 9

To make sure the file exists and is writable by the web server, use the commands shown below.  Note that I'm using the default 'apache' user and group here.  Your web server may run under a different user...use the user appropriate to your configuration:

# touch /var/log/rewrite.log
# chown apache:apache /var/log/rewrite.log
# chmod 644 /var/log/rewrite.log

Now restart your web server.  When you try browsing to the URL, mod_rewrite should start logging the debug output into the file you've chosen.  Examine the log file...it is very thorough, and a close inspection of it usually points out the error right away.  Post the results here and I'll show you how.
Random Solutions  
 
programming4us programming4us