WordPress.org

Ready to get started?Download WordPress

Forums

Simple 301 Redirects
Can you redirect without using 'http://www..' ? (5 posts)

  1. Jason Paul
    Member
    Posted 3 years ago #

    I'm in the process of switching an old site to a new WordPress site. I'd like to do all the 301 redirects on the dev site so they're already in place when we re-point the DNS. I can see this being a problem as the dev site isn't yet configured to have the correct full url. Is it possible to redirect using a relative path instead of the full url?

    http://wordpress.org/extend/plugins/simple-301-redirects/

  2. scottnelle
    Member
    Plugin Author

    Posted 3 years ago #

    Hi Jason,
    Relative paths work, but they have to be relative to the root of the domain. That is to say, if you install wordpress at domain.com/blog/ then all of your destination urls will have to be either full URLs or start with /blog/. If WordPress is installed in the root you should have no problems.

  3. Jason Paul
    Member
    Posted 3 years ago #

    Thanks. I think that answers my question. Another fork of that question...
    If I do full path redirects on the dev server will they create any conflicts? Or will they snap into place and work when the dev site becomes the live site?

    example:
    old: http://site.com/oldpathblabla.asp
    new: http://site.com/newpath/
    (meanwhile the dev server still has a path like http://devsite.com until DNS is repointed)

    Really just wondering if I should take the risk and wait to do the 301 redirects when the site is actually live and risk being crawled by Google and losing some clicks while updating links or if they can be done in advance.

  4. scottnelle
    Member
    Plugin Author

    Posted 3 years ago #

    I think I'm following you. If you use full path destinations on the dev site, the pages won't work until you go live. That is to say, if you specify that /oldpathblabla.asp should redirect to http://site.com/newpath/, it will always go to the full path. so if you went to http://devsite.com/oldpathblabla.asp it would redirect you to the full path that you specified (http://site.com/newpath/) and not automatically figure out that you wanted http://devsite.com/newpath/

    Hope that answers your second question.

  5. Matthew Boynes
    Member
    Posted 2 years ago #

    It should be noted here that relative paths, while they work in most web browsers, are invalid according to spec. Therefore, they aren't guaranteed to work in every application.

    http://tools.ietf.org/html/rfc2616#section-14.30
    http://en.wikipedia.org/wiki/HTTP_location

    Scott, a good solution would be, if a path started with '/', automatically include the current domain in the Location header.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic