WordPress.org

Ready to get started?Download WordPress

Forums

Old links does not work after Changing my Own Directory and permalinks (2 posts)

  1. elitost
    Member
    Posted 6 years ago #

    Hello,

    I changed my Own Directory with the procedure described in the Help section, now my blog is accessible with :

    http://ericreboisson.free.fr

    instead of :

    http://ericreboisson.free.fr/wordpress

    And after I recalculated the permalinks :

    http://ericreboisson.free.fr/index.php/2008/03/31/activation-des-permaliens-sur-un-hebergement-freefr/

    Now, my problem is, for each old links without permalink calculation i have a 404 error :

    http://ericreboisson.free.fr/wordpress/?p=332

    This error happens on my internal links I used in my post, but also for all the previous links indexed by Google, Yahoo...

    What can I do to solve the problem ?

    Thanks by advance

  2. Austin Matzko
    Member
    Posted 6 years ago #

    There are at least two ways to fix your internal links. (This won't fix the indexed links of Google).

    The first, easiest and safest, is to replace the text on output. One way to do this is to put the following line in your theme's functions.php template:

    add_filter('the_content', create_function('$a','return str_replace("http://ericreboisson.free.fr/wordpress","http://ericreboisson.free.fr",$a);'));

    The second, permanent and more dangerous, is to replace the text in your database. I say dangerous, because if you mess this up, you could really mess up your posts. You must back up your database before trying this, and you shouldn't attempt it if you feel uncomfortable at all about it. I'm telling you how to do it, not saying that you should.

    If you did this, you would run the following query, using phpMyAdmin or the like:

    UPDATE wp_posts SET post_content=REPLACE(post_content, "http://ericreboisson.free.fr/wordpress","http://ericreboisson.free.fr");

Topic Closed

This topic has been closed to new replies.

About this Topic