How to Exclude a file from redirection in a website

If you have already followed “Redirect primary domain name to directory inside / subdirectory” to redirect all URLs from website to subdirectory using redirect rules and now wanted to exclude some URLs or some directory from redirecion, 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