I have a WordPress site at example.com/blog. Now I want to remove the /blog subdirectory and just keep example.com.

However, other sites that are referencing my site still point to example.com/blog. How can I redirect all traffic including posts and pages going to example.com/blog to example.com?

1 Answer 1


Assuming you have already moved your site from the /blog subdirectory to the document root and changed the URL structure within WordPress itself, so the /blog subdirectory is not included in all your internal links, then you can either do a simple redirect (using mod_rewrite) in the /blog/.htaccess file (preferable):

RewriteEngine On
RewriteRule (.*) /$1 [R=302,L]

This will redirect a URL of the form /blog/foo to /foo, since the captured backreference ($1) does not contain the directory-prefix when used in a directory context.

Alternatively, if you want to delete the /blog subdirectory altogether then you can do something like the following at the top of the root .htaccess file, before the WordPress front-controller:

RewriteRule ^blog/(.*) /$1 [R=302,L]

Note that these are currently 302 temporary redirects. Only change to 301 permanent redirects when you are sure they are working OK.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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