WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] 301 redirect and permalinks (8 posts)

  1. DotsConnected
    Member
    Posted 2 years ago #

    I'm using permalinks and I'm trying to 301 redirect my non-www url to my www url. I thought this would be a simple procudure adding some rules to my .htaccess, but it's not. Either it screws over my permalinks or it doesn't work at all.

    Does anyone have a solution for this?

    Thanks,
    Sabra

  2. First, be sure to put the www/non-www rules completely above and outside the standard WordPress permalinks block of code.

    This is what I use:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^yourdomain.com
    RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]

    If it doesn't work, try contacting your host or looking in their documentation, as some hosts require different syntax.

  3. DotsConnected
    Member
    Posted 2 years ago #

    Thanks for taking the time to reply! I contacted my host because your solution still resulted in a 404 error when using the non-www url. I'm gonna see what they have to say and report back. :)

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 2 years ago #

    Doing this yourself is generally unnecessary; WordPress handles canonical redirection automatically. If your site's settings has the www in the site and blog url, then it will redirect to that url when another request comes in on the wrong URL.

  5. DotsConnected
    Member
    Posted 2 years ago #

    I'm afraid it doesn't in my case, or I'm doing something wrong. I have my url (www.gentlemenswatch.com) in both site and blog url. But when I navigate to gentlemenswatch.com it gives me a 404.

  6. That sounds like a hosting misconfiguration. Let us know how it goes.

  7. DotsConnected
    Member
    Posted 2 years ago #

    Well, my host solved the problem with something called a symbolic link. Whatever that may be. :)

  8. Perfect. :-)

Topic Closed

This topic has been closed to new replies.

About this Topic