Force Redirect www.domain.comblog to domain.comblog .htaccess?

I have a wordpress Multisite instance that for some reason defaults to domain.com (/blog with no www in front. Any request with a www in front gets forced to the home page (domain.com/blog) and not to it’s intended page of say domain.com/blog/page.

What I am trying to do is force all incoming traffic to strip off www if it exists and just go to /blog/what-ever-page-youre-trying-to-go-to. I need it to go to the page that is requested, currently if you have anything on the end of the /blog URL (/blog/ANY-PAGE-HERE) it defaults to /blog.

Read More

Anyone have any idea how I would go about fixing this? In .htaccess seems to be the easiest way but I can’t seem to find a viable solution after working on it for a couple of hours.

PS: it’s multisite so I cannot just go into setting and change the URL and HOME to www.domain/blog

Related posts

Leave a Reply

2 comments

  1. This is what I use on my sites:

    <IfModule mod_rewrite.c>
      RewriteEngine on
    
      # If your site can be accessed both with and without the 'www.' prefix, you
      # can use one of the following settings to redirect users to your preferred
      # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
      #
      # To redirect all users to access the site WITH the 'www.' prefix,
      # (http://example.com/... will be redirected to http://www.example.com/...)
      # adapt and uncomment the following:
      RewriteCond %{HTTP_HOST} ^domain.net$ [NC]
      RewriteRule ^(.*)$ http://www.domain.net/$1 [L,R=301]
    </IfModule>
    
  2. Add this above all your wordpress stuff in the htaccess of your document root:

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