Exclude a file or 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 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.

READ  How Android Bluetooth Profiles are enabled & Services activated ?

Leave a Reply

Your email address will not be published. Required fields are marked *