Due to search engine crawling errors, I need to redirect websites of non existing subfolders to a reachable website.

This is what is currently leading to 404-errors:

  • www.domain.tld/subfolder1/tag1/
  • www.domain.tld/subfolder1/tag2/
  • www.domain.tld/subfolder1/tag3/

Therefore I simply want to redirect the above URLs to the root domain.

The following code is heading to www.domain.tld/tag3/ (which is not what I need)

RewriteRule ^subfolder1/(.*)$ /$1 [R=301,NC,L]

Can anybody help me out what to modify in the .htaccess-file, that all URLs with subfolder1 are redirected to www.domain.tld?

  • Why don't the Subfolders Exist? Are you perchance using PrettyPermalinks? See the section on .htaccess
    – eyoung100
    Jun 19, 2014 at 22:30
  • Thanks for your comment. The subfolders dont exist anymore because I changed the permalink structure.
    – Traveler
    Jun 19, 2014 at 22:37
  • As I suspected, read the Codex... Your either gong to need to update the htaccess file manually using the example provided in the Codex, or check your write Permissions, then go into the Permalinks admin, and resave the changes with the new write permissions enabled.
    – eyoung100
    Jun 19, 2014 at 22:42
  • I finally found a solution for my problem. Please see my answer below.
    – Traveler
    Jun 19, 2014 at 22:43
  • Glad I got to help Welcome to SE
    – eyoung100
    Jun 19, 2014 at 22:48

1 Answer 1


This is the solution I finally found after many hours investigation:

RewriteRule ^subfolder1/(.*)$ http://www.domain.tld [R=301,NC,L]

With the above code in the .htaccess-file, which is located in your websites root directory, all URLs which contain www.domain.tld/subfolder1/* are redirected to the root domain.

Hope this will help anybody else than me :-)

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.