1

I have a wordpress blog, and having issue with URL's.. Few months ago i used link with slug (Forcely changed to blog when i switched to MultiSite) like this, example.com/blog

Now I am using wordpress without BLOG and removed slug "BLOG" after link.

Problem is many quality backlinks i have with old blog slug.
When someone visit my blog with example.com/blog/post-permalink it redirects to not_found_404 error because link should be looks like this, example.com/post-permalink.

I am confused, how to redirect every request that comes with example.com/blog/post-name and redirect to example.com/post-name

2
  • There are hundreds of redirect plugins you could use, I like this one: wordpress.org/plugins/safe-redirect-manager Commented Mar 16, 2016 at 14:22
  • yes but i want to solve this issue by using .htaccess Commented Mar 19, 2016 at 14:32

1 Answer 1

1

Redirecting pages below /blog/

It should be as simple as a .htaccess in your domain root directory (where index.php lives) with the following contents:

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

Note that RewriteEngine on is required only once per .htaccess file, so skip this if it is present already.

The RewriteRule itself matches all URL beginning (^) with blog/ and catches everything following until the end ($). The caught part is stored in the reference $1.

This reference is thereafter used in the redirection target, as /$1.

L means that no further rules in the .htaccess are evaluated.

R=301 redirects using a HTTP/1.1 301 Permanent redirect, which is desirable for SEO and redirects all visitors to the new URL.

Redirecting /blog itself

In addition to the above insert

RewriteRule ^blog(/?)$ / [L,R=301] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.