[resolved] htaccess redirect? (3 posts)

  1. jpettit
    Posted 11 years ago #

    i misnamed a post, and want to change it. however google, etc have picked up the old, misnamed post title that is no longer valid.

    what do i need to add to htaccess to get the old title to redirect to the new title? this is what i have tried with no luck:

    Redirect permanent /archives/2005/07/05/oldname/ http://domain.com/archives/2005/07/05/newname/

    when i attempt to go to:
    i get redirected to:

    also some strange behaviour i just encountered...when i go to:
    (note the double forward slash)
    i get redirected properly.

    my WP is installed at /wordpress
    can anyone shed some light on what i am doing wrong. i realize that the links are 'permalinks' which are generated on the fly, so how can i redirect posts? thanks.

  2. Kafkaesqui

    Posted 11 years ago #

    As you can see a redirect hooks the query to the end of the link; to override it slip an empty query (? with nothing else) onto the end of the 'direct to' url:

    Redirect permanent /archives/2005/07/05/oldname/ http://domain.com/archives/2005/07/05/newname/?

    Will look a bit strange, but it works.

    Another option is to eschew .htaccess entirely and stick a "redirect" in the index.php of your blog's root. In the php tag you'll find there, just above the require line (for wp-blog-header.php), insert:

    if(isset($_GET['name']) && $_GET['name'] == 'oldname') {
    header("Location: http://domain.com/archives/2005/07/05/newname/");

  3. jpettit
    Posted 11 years ago #

    thanks Kafkaesqui...i knew someone on here would know!
    i went for the empty query 'fix' and all works as it should.
    thanks again!

Topic Closed

This topic has been closed to new replies.

About this Topic