301 redirect all traffic from a subdirectory to root url Print

  • 2

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]

Was this answer helpful?

« Back