What if you need permanently redirect your dynamic URLs to static pages?
I.e. http://www.site.com/news.php?id=1234 you want redirect to more “beautiful” URL like http://www.site.com/news-about-good-thing.php
Easy answer: use .htaccess
Put these lines of code:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=1234
RewriteRule ^/news\.php$ http://www.site.com/news-about-good-thing.php? [R=301,L]
Leaving ^id= blank you will permanently redirect all “news” pages to a selected new URL.
If you have your “news” in subfolder, then your code will look like this:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=1234
RewriteRule ^worldwide/news\.php$ http://www.site.com/news-about-good-thing.php? [R=301,L]
or
RewriteEngine On
RewriteCond %{QUERY_STRING} ^id=1234
RewriteRule ^worldwide/news\.php$ http://www.site.com/worldwide/news-about-good-thing.php? [R=301,L]




