DEV Community

Amit Verma (amitoverflow)
Amit Verma (amitoverflow)

Posted on

301 reditect a domain with exception

Here is the simple mod_rewrite rule that will help you redirect your site URL to another domain with exception. Assuming we have a domain named "foo.example.com" and we want to redirect all our site traffic to an external domain "bar.example.com" with an exception that our /admin/ directory should not redirect, we can use the following in htaccess :

RewriteEngine on

RewriteRule !admin https://bar.example.com [L,R=301]

See the full article on this page : https://helponnet.com/2021/05/01/redirect-domain-with-exception/

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay