I am reviving/reorganising my personal WordPress blog.

It's using a URL that looks like this:


The webserver 301 redirects www.mydomain.com to mydomain.com.

I want to use the blog subdirectory because I plan to add other parts to the site, with the blog only being one part of the site.

However, at the moment there is nothing there but the blog, so I want to have the root index page redirect to the blog for the time being.

I have been using this on the root index.html page to do the redirect...

<meta http-equiv="REFRESH" content="0;url=./blog">

...but this seemed to have stopped the site being indexed by Google and Bing.

How do I do this without affecting SEO? Also, what URL should I put in the sitemap.xml?

1 Answer 1


You could rewrite URLs internally in your root .htaccess file.

RewriteEngine On

#if request is mydomain.com/something OR
RewriteCond %{HTTP_HOST} ^mydomain\.com$ [OR]

# or www.mydomain.com/something
RewriteCond %{HTTP_HOST} ^www\.mydomain\.com$

# but not mydomain.com/blog
RewriteCond %{REQUEST_URI} !^/blog/

#change it to mydomain.com/blog/something
RewriteRule (.*) /blog/$1 [R=301]

Or, if you want to apply a temporary solution till you develop the other parts of site, you could place an index.php in the root with this following code:

Header( "HTTP/1.1 301 Moved Permanently" ); 
Header( "Location: http://www.mydomain.com/blog" ); 

Benefits of this approach is that no present/possible messing up of URLS. And it is simpler than .htaccess approach. Also this will tell Google that this page moved permanently ( or temorary with 302) to this new location. (Although [R=301] in .htaccess would have done same thing.)

Here is a discussion about 301 & 302 redirects by Matt Cutts

  • Updated with php redirect approach.
    – DavChana
    Sep 8, 2012 at 5:05
  • I like the way the .htaccess method is working, but I am not sure how the it is going to be indexed, as Google may not like the fact that http://mydomain.com and http://mydomain.com/blog are exactly the same. Does what I out in the sitemap.xml make a difference to what and how it is going to be indexed?
    – paradroid
    Sep 8, 2012 at 6:13
  • Sorry, no SEO expert.. But you could use Flag 301 (Moved Permanently) in .htaccess code. It tells Google & other visitors/browsers that mydomain.com is permanently moved to mydomain.com/blog Updated .htaccess code with this change.
    – DavChana
    Sep 8, 2012 at 6:39
  • 1
    Regarding the URL you use in sitemap.xml it would make sense to only include the URL that you are actually serving content from and the one that will appear in the SERPS, ie. http://mydomain/blog/.
    – MrWhite
    Sep 8, 2012 at 11:14
  • @Davinder: I'm using the index.php method (the .htaccess method causing other directories to be inaccessible). I'm sure, but it looks like all pages but the homepage has been wiped off Google SERPs, just like they were when I was using the meta refresh method I mentioned in the question. So is Google does not index 301 redirects? I feel like I'm back to square one.
    – paradroid
    Sep 10, 2012 at 23:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.