WordPress.org

Ready to get started?Download WordPress

Forums

Blog posts and pages redirecting to homepage (2 posts)

  1. pantone
    Member
    Posted 2 years ago #

    When I setup multisite, I decided to keep my site URL to include the www. Basically, anytime a user types in the URL of my homepage in their browser as a non-www, it will redirect to the www version, which is how I want it.

    However, for the URLs of individual blog posts and pages, when non-www is entered, it redirects to the homepage and not the blog post or page itself.

    Any idea how to fix this? I imagine I have to setup a rewrite rule in the htaccess file?

  2. And that's reason #2 why I advocate NOT using www. *sigh* (Web servers are just plain inconsistant.)

    If you're not mapping domains, OR using Subdomains, try this:

    # Redirect non-www urls to www
    RewriteEngine on
    RewriteCond %{HTTP_HOST} !^www\.example\.com
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    If you are using Subdomains, try this:

    # Redirect non-www urls to www
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^example\.com [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    If you're using mapped domains, it's a nightmare, and just map both www and non-www versions of the URL, set the www as primary and let the plugin sort it out.

Topic Closed

This topic has been closed to new replies.

About this Topic