Forum Moderators: phranque
I am using an old version of my CMS (from another one of my websites) on a new website and I need to change the new urls to search engine friendly urls and redirect all pages that are already indexed in search engines to the new urls.
I can't figure out how to fix these issues and I would greatly appreciate any help I can get to solve this:
I have many pages like this url: www.example.com/articles.php?art_id=1234 (dynamic id/digits at the end of url)
# As a newbie, I added this to .htaccess to start to rewrite the url
Options +FollowSymLinks
RewriteEngine on
RewriteRule articles-art_id-(.*)\.htm$ articles.php?art_id=$1
This works to get rid of the ".php?" BUT probably not the best solution. I am also able to change the word "articles" to any word and get it to work (but I still need to add a 301 redirect for all existing pages to find the "new" pages).
I keep thinking that the best way to do all of this is to find a new way. So here is the original problem:
1. I want to change all urls like this: articles-art_id- .. to something better (more search friendly).. preferably using the PAGE TITLE in the url (from MySql database) .. so something like this: /articles/page-title-here OR /articles-page-title
2. I also need to "301 redirect" all urls that are already in google, yahoo, etc. to the new pages without having to manually redirect more that 1000 pages.
Does this explanation make sense? Can you please help me figure this out? Any help is really, really appreciated!
Thanks
So your best bet might be to simply rewrite *all* URLs that start with article-art-id to your script (or to a new script), and have the script open your database, look up the title associated with the old page's new URL, build that new URL, and then issue a 301-Moved Permanently redirect to that new URL from within the script.
If no replacement for the old-style URL can be found in the database, or if the requested old-style URL is invalid, then the script must issue a 404-Not Found -- or a 410-Gone for the case where you know you don't have (or want) a replacement URL.
Jim