How does wordpress do redirects?

Discussion in 'Search Engine Optimization' started by dcristo, Jul 3, 2008.

  1. #1
    When you edit the page name for a blog post, you will notice the old page will redirect to the new page. I looked at .htaccess and nothing was changed, and there doesnt seem to be meta redirects added to the source code. So how is the redirect done?
     
    dcristo, Jul 3, 2008 IP
  2. astup1didiot

    astup1didiot Notable Member

    Messages:
    5,926
    Likes Received:
    270
    Best Answers:
    0
    Trophy Points:
    280
    #2
    I believe it's done via the database and just injects the meta redirection on the fly. I suggest using a true 301 redirect plugin or actually editing your .htaccess file yourself.
     
    astup1didiot, Jul 3, 2008 IP
  3. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I'm pretty sure that's how it works as well, ssandecki. FINDING the PHP and MySQL code that does it on the other hand... well, I hope you like sphagetti because that's what the code is like...
     
    Dan Schulz, Jul 3, 2008 IP
  4. MeetHere

    MeetHere Prominent Member

    Messages:
    15,399
    Likes Received:
    994
    Best Answers:
    0
    Trophy Points:
    330
    #4
    its via htaccess redirect for sure.
     
    MeetHere, Jul 3, 2008 IP
  5. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    437
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It's not. .htaccess only handles the base canonical URI issue, and even that it can't handle properly.
     
    Dan Schulz, Jul 3, 2008 IP
  6. kentuckyslone

    kentuckyslone Notable Member

    Messages:
    4,371
    Likes Received:
    367
    Best Answers:
    0
    Trophy Points:
    205
    #6
    When you change the page name it does not change the url of the page. If you originally named a post The Secrets of Gidgets the url would be ....the-secrets-of-gidgets then if you renamed the post to The Secrets of Widgets the url would still be ....the-secrets-of-gidgets (unless you edit that too)

    If you changed the title but not the url then there is no redirection happening -- just an idea
     
    kentuckyslone, Jul 3, 2008 IP
  7. Brandon Sheley

    Brandon Sheley Illustrious Member

    Messages:
    9,721
    Likes Received:
    612
    Best Answers:
    2
    Trophy Points:
    420
    #7
    I didn't know that it would redirect if you changed the permilink?
    guess ya learn something new every day ey :D
     
    Brandon Sheley, Jul 3, 2008 IP
  8. doremon20042005

    doremon20042005 Peon

    Messages:
    28
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    How to implement the 301 Redirect

    1. To create a .htaccess file, open notepad, name and save
    the file as .htaccess (there is no extension).

    2. If you already have a .htaccess file on your server,
    download it to your desktop for editing.

    3. Place this code in your .htaccess file:

    redirect 301 /old/old.htm hxtp://www.you.com/new.htm

    4. If the .htaccess file already has lines of code in it,
    skip a line, then add the above code.

    5. Save the .htaccess file

    6. Upload this file to the root folder of your server.

    7. Test it by typing in the old address to the page you've
    changed. You should be immediately taken to the new
    location.

    Notes: Don't add "http://www" to the first part of the
    statement - place the path from the top level of your site
    to the page. Also ensure that you leave a single space
    between these elements:

    redirect 301 (the instruction that the page has moved)

    /old/old.htm (the original folder path and file name)

    hxtp://www.you.com/new.htm (new path and file name)

    When the search engines spider your site again they will
    follow the rule you have created in your .htaccess file.
    The search engine spider doesn't actually read the
    .htaccess file, but recognizes the response from the
    server as valid.

    During the next update, the old file name and path will be
    dropped and replaced with the new one. Sometimes you may
    see alternating old/new file names during the transition
    period, plus some fluctuations in rankings. According to
    Google it will take 6-8 weeks to see the changes reflected
    on your pages.
     
    doremon20042005, Jul 3, 2008 IP
  9. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #9
    No its not. I checked .htaccess and it wasnt edited. I used a redirect checker for the old URL and it returned a 301 redirect so I am happy.
     
    dcristo, Jul 3, 2008 IP
  10. kentuckyslone

    kentuckyslone Notable Member

    Messages:
    4,371
    Likes Received:
    367
    Best Answers:
    0
    Trophy Points:
    205
    #10
    Did you actually edit the permalink or just the title of the post?
     
    kentuckyslone, Jul 3, 2008 IP
  11. dcristo

    dcristo Illustrious Member

    Messages:
    19,797
    Likes Received:
    1,201
    Best Answers:
    7
    Trophy Points:
    470
    Articles:
    5
    #11
    sorry I wasnt clear. I edited the URL structure by editing the page title and deleting the old URL so it would make the new URL changes.

    You are correct, changing the title on its own will not change the URL.
     
    dcristo, Jul 3, 2008 IP
  12. kentuckyslone

    kentuckyslone Notable Member

    Messages:
    4,371
    Likes Received:
    367
    Best Answers:
    0
    Trophy Points:
    205
    #12
    Well then that is a new one on me. I didnt know that WP would redirect like that, very interesting!
     
    kentuckyslone, Jul 3, 2008 IP