Forum Moderators: phranque
At my site I use the following permalink format:
www.example.com/article1234.htmlwhere 1234 = storyID
Now, the CMS I use has a new version and... a new permalink format. This one:
www.example.com/storyID/title-of-the-article/
Obviously, I don't want to loose relevance at search engines, so, before to use the new version of my CMS at a production site, I need to know how to redirect the old permalinks to the new ones.
I think I can do it adding a rule at the '.htaccess' file but... all the methods I've tried to apply (Redirect 301, RewriteRule, etc) don't work :-(
I've read many tutorials, but I still don't know how to do it. Any solution?
Thanks.
[edited by: Abadia at 10:59 pm (utc) on July 16, 2008]
[edited by: jdMorgan at 6:46 pm (utc) on July 17, 2008]
[edit reason] example.com [/edit]
How many permalinks do you have to rewrite?
How do you plan to associate article1234.html with storyID/title-of-the-article/?
Do you have access to httpd.conf, conf.d or some other server-configuration file, or just .htaccess?
I'd do it in the script, using a database that has lists of the old URLs against new URLs.
I'd do it in the script, using a database that has lists of the old URLs against new URLs.If I have understood you correctly, you think I should associate every single permalink one by one, isn't it? Well, I can't do it because I've written more than 3000 articles, and every day I write a couple more
One way or the other, you'll have to build a table to associate the old article1234 URLs with the new storytitle URLs. You can do this in a separate database, or within the new CMS's database.
Then you have a second choice to make. You can either modify the main CMS script to recognize and redirect old article URLs, or you can write a separate script, invoked by mod_rewrite, to open the database and look up the new new article URL by using he old URL, and redirect to it. (See mod_rewrite's RewriteMap directive.)
Either way, you need a translation for each of the old article URLs, because the server itself will have no idea how to associate the old URL with the new... This is true of *any* method, including those that are more difficult than those described above.
New articles are of no concern, since they will never be requested using an 'old' URL.
Jim
Well, thanks to your posts I know I must create a table with the associations, but I have some doubts:
1. Is there any problem if I create the table directly at the .htaccess file or it should be better if I create it in other file?
2. In order to improve the SEO of my site/articles, which kind of permalinks you think are better?
www.example.com/storyID/title-of-the-article/
[i](storyID = a number between 0 and 3250 which represents the number of the article)[/i]
or
www.example.com/title-of-the-article/
3. These rules are correct to associate the old permalinks with the new ones?
Redirect 301 /article1.html /title-of-the-article-1/
Redirect 301 /article2.html /title-of-the-article-2/
Redirect 301 /article3.html /title-of-the-article-3/
...
...
Redirect 301 /article3250.html /title-of-the-article-3250/
[edited by: Abadia at 5:46 pm (utc) on July 17, 2008]
[edited by: jdMorgan at 6:43 pm (utc) on July 17, 2008]
[edit reason] example.com [/edit]
As I said before, the most efficient method from both an implementation and maintenance standpoint would be to add a record to your CMS database giving the "old" URL, and then modify your CMS script to redirect any request it gets for an old URL to the new one. You haven't responded to that idea, and I cannot recommend putting 3000 redirects into an .htaccess file -- You're likely to suffer server performance problems if you do it that way.
As far as "SEO" factors go, the less "junk" your URL contains, the better. So unless carrying "StoryID" in the URL confers some advantage, I'd drop it. And if it does confer an advantage, then put it at the end of the URL-path, not the beginning.
There are two possible advantages: First if the new StoryID is the same as the old article number, then you could potentially do all these redirects with one rule, not 3000. Second, as the number of your posts grows, you may eventually end up with two identical titles. In that case, the StoryID would still be different, and allow you and your CMS to tell them apart.
[added]
You need to specify the full URL of the new URL:
Redirect 301 /article1.html http://www.example.com/title-of-the-article-1/
[/added]
Jim
[edited by: jdMorgan at 6:44 pm (utc) on July 17, 2008]
As I said before, the most efficient method from both an implementation and maintenance standpoint would be to add a record to your CMS database giving the "old" URL, and then modify your CMS script to redirect any request it gets for an old URL to the new one.
I have no idea on how to implement what you tell me :-(
There are two possible advantages: First if the new StoryID is the same as the old article number, then you could potentially do all these redirects with one rule, not 3000.
The storyID number is the same in both permalink formats (old and new). Before starting this post, I tried to create a unique rule to redirect from the old URL format to the new one without success. Then I misunderstood your comment and I thought that I had to create a table... but as you have explained me in your last comment, 3000 redirects are too much redirects :-)
Second, as the number of your posts grows, you may eventually end up with two identical titles. In that case, the StoryID would still be different, and allow you and your CMS to tell them apart.
I hadn't thought on that case, but obviously, there is a huge possibility that two or more titles will be exactly the same, so maybe it could be a good idea to use (if finally I find the method to redirect all the URLs) a format, for example, like these ones:
http://www.mysite.com/title-of-the-article/storyID
or
http://www.mysite.com/title-of-the-article-storyID
[edited by: Abadia at 11:43 pm (utc) on July 17, 2008]
One more question: Does a URL like www.example.com/storyID/ or www.example.com/storyID/random-text/ work in your new CMS? -- Does it find the correct "story" based on the storyID alone? (Never mind that it's not your end-goal to use such a URL.)
Jim