Forum Moderators: phranque
I have a page on my domain 'news.php' which dynamically serves news, or it did, then I moved it to '/NewsAndFeatures/index.php'.
When the page is called it's passed a querystring in the format:
index.php?news_ID=43
What I need to do is route all incoming requests for news items at the old address...
news.php?doc_ID=43
...to the new address...
/NewsAndFeatures/index.pgp?news_ID=43
I 'thought' that this would do the trick, but something in the originating URL is causing it to break.
RewriteRule ^news\.php?doc_ID=([0-9][0-9])$ NewsAndFeatures/index.php?news_ID=$1 [R]
Any ideas?
Welcome to WebmasterWorld!
You'll need to use RewriteCond to handle the query string. Query strings are not considered part of the URL, but rather, data to be passed to the resource *at* the given URL. Therefore, query strings are not 'visible' to RewriteRule for pattern-matching.
For use in .htaccess:
RewriteCond %{QUERY_STRING} ^doc_ID=([0-9]{2})$
RewriteRule ^news\.php$ http://www.example.com/NewsAndFeatures/index.php?news_ID=%1 [R=301,L]
Jim