I moved WordPress out of the root of my server into a special folder of its own and now Google is indexing my posts together with that special WordPress folder thus creating some 404 error issues.

For example let's say my WordPress core files are installed in https://www.example.com/wordpress/ but the home page is https://www.example.com/.

This post link https://www.example.com/hello-world/435/ works fine and has been indexed by Google. Unfortunately, Google is also indexing https://www.example.com/wordpresshttps://www.example.com/hello-world/435/ thus creating 404 errors in Google Search console.

So my question is, is there a way to use .htaccess to make links like https://www.example.com/wordpresshttps://www.example.com/hello-world/435/ to redirect to the right link which is https://www.example.com/hello-world/435/?


1 Answer 1


I've fixed it using the rule below

RewriteRule ^(.*)wordpresshttps:/www.example.com/(.*)$ https://www.example.com/$2 [L,R=301]
  • If you are seeing URLs like https://www.example.com/wordpresshttps://www.example.com/hello-world/435/ indexed in the SERPs then it suggests you have an error with your internal links (this isn't the result of simply moving WP to a subdirectory). Unless you have fixed this underlying error with your links then simply implementing a redirect in .htaccess (which you will need to do anyway for SEO) will not be a satisfactory "fix". Google wouldn't be "indexing" these URLs unless it found them somehow. (Although why it would index 404s is another matter - have these always been 404s?)
    – MrWhite
    Commented Jan 9, 2019 at 20:01
  • @MrWhite when I made the move, I scanned thoroughly for such errors and found none. At the moment I can't find where (on my site) Google is getting those bad links from. Like you said, it's strange google will be indexing 404 errors. Ever since I detected those URLs, they've always thrown up 404 errors Commented Jan 10, 2019 at 6:49

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.