• Resolved Mian Shahzeb

    (@mianshahzeb)


    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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Mian Shahzeb

    (@mianshahzeb)

    thanks this one works..
    another solution i got for this.

    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]

    Hi,

    Another best plugin is Redirection. You can solve the URL issue by using this plugin.

    Thread Starter Mian Shahzeb

    (@mianshahzeb)

    Thanks nisha, i will take give a try too.
    Anyhow .htaccess solution is working perfect for this problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘URL Redirect php or .htaccess in WordPress’ is closed to new replies.