WordPress.org

Ready to get started?Download WordPress

Forums

Premalinks change (5 posts)

  1. DinoCSP
    Member
    Posted 2 years ago #

    Hi all,

    I was hoping if someone could help me with my quest here, I have my premalink structure /%category%/%postname%/, now I need it to be /%category%/%postname%.html so my Social reader app could publish actions to FB users profiles, but my problem is that I have then 1900 broken links that users previously bookmarked, so my question is: Is there any way to make once I turn them to /%category%/%postname%.html and people try to access /%category%/%postname%/ the link gets redirected to /%category%/%postname%.html whether it be a function that changes last slash into .html (because that is the only change in the structure) or anything?

    So is there any way to accomplish that?

  2. saishuhane
    Member
    Posted 2 years ago #

    http://wordpress.org/extend/plugins/redirection/

    I would suggest using this plugin and when defining a new rule for 301, use the regular expression:

    Source URL: (.*)/(.*)
    Target URL: (.*)/(.*)\.html

    Pretty sure this will work. Unless you have pages that are like %postname%/comment-page-1 .

  3. DinoCSP
    Member
    Posted 2 years ago #

    Nope, the (.*)/(.*) not possible, nothing happens... it looked logical to me too... but no.

  4. Henry
    Member
    Posted 2 years ago #

    If you do this you also run the risk of loosing any Google juice you've accumulated for your existing URLs.

    If you have lots of people linking to:

    http://www.example.com/hello-world

    Then this link will be ranked high in Google search results. Changing the URL will not only break inbound bookmarks and links, you will also lose valuable ranking weight.

  5. DinoCSP
    Member
    Posted 2 years ago #

    Solved the issue by changing the 404 page just added

    <?php
    $dino_removed_slash = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
    $dino_removed_slash = rtrim($dino_removed_slash,'/')
    ?>
    Proceed with the <a href="http://<?php echo $dino_removed_slash(); ?>.html">article</a>

    Unfortunately that is the only way, because opengraph api wont publish actions related to posts finishing with "/"... at least in my case.

    Hope this solution up there helps someone out there.

Topic Closed

This topic has been closed to new replies.

About this Topic