301 redirect all traffic from a subdirectory to root url

If you need to redirect all the traffic from a subdirectory to the root of the site, use the htaccess below.

For example:  www.domain.com/hello/ -> www.domain.com

The htaccess below will use the relative URL redirect to go to the root of the site.

######################################
# Redirect /subdirectory/ to root url
# see: https://www.jucra.com/whmcs/knowledgebase/181/
######################################
RewriteRule ^SUBDIRNAME/(.*)$ / [R=301,NC,L]
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Solving the ERR_BLOCKED_BY_XSS_AUDITOR in Chrome

You are reading this article because you have saved something in wordpress and received an error...

Additional security/performance settings for htaccess

Below is some additional rules for your htaccess file which provides some performance and...

Forcing SSL and WWW in htaccess

Use the following code in the htaccess file for making sure that all pages served up are www and...

301 redirect all traffic from domain A to the root of domain B

If you need to 301 redirect all the traffic from olddomain.com to the index page of newdomain.com...

Fix WordPress 404 Errors on Password Protected Directories

You are reading this article becasue you have applied password protection on the wp-admin...