Home » Web Design and Development » Search Engine Optimisation ( SEO ) » Exclude website directory from redirecting using .htaccess rewrite rules

Exclude website directory from redirecting using .htaccess rewrite rules

If you have already followed “Redirect primary domain name to directory inside / subdirectory” to redirect all URLs from website to sub-directory using redirect rules and now wanted to exclude some URLs or some directory from redirection, append below lines after “RewriteEngine On” in .htaccess as,

RewriteEngine On
RewriteRule ^(/|wp-login\.php) - [L]
RewriteRule ^(/|wp-admin) - [L]

So in above case, we tried to avoid redirection of WordPress login www.yourwebsite/wp-login.php and all urls from directory www.yourwebsite/wp-admin/
hence in general, the rule can be considered as,

RewriteRule ^(dir_name|file_name\.extension) - [L]


here, you can add as many files or directories using OR | operator.

Leave a Comment