.htaccess – How to redirect all of your traffic to another web site, *except* for some URLs?

Let’s say you have a .htaccess file. How to redirect all of your traffic to another web site, except for some URLs?

The code is the following, it does 301 redirect (the first two lines are for redirecting the homepage, then for all other URLs. Of course, you should change “olivian.ro” to your needs.

Options +FollowSymLinks
RewriteEngine on
 RewriteRule ^$ https://olivian.ro/categorie/im [R=301,L]
RewriteEngine on
 RewriteRule (.*) https://olivian.ro/$1 [R=301,L]

Note: for other uses, you can also use a .htaccess generator:
.htaccess Generator Wizard
[en] .htaccess Editor
Mod Rewrite Generator by GenerateIt.net

Ruiwen Chua - code.close(), https://flic.kr/p/5Y5QPG
Ruiwen Chua – code.close(), https://flic.kr/p/5Y5QPG

Note: Also see the Yahoo! Group on which I present similar issues:IMRo. To join, email imro-subscribe@yahoogroups.com and reply to the confirmation email.

I am a Digital Marketing Manager for The KPI Institute. My expertise is in SEO (Search Engine Optimization) / UX (user experience) / WordPress. Co-founder of lumeaseoppc.ro (series of events on SEO & PPC) and cetd.ro (Book on branding for MDs). On a personal level, I like self-development - events, sports, healthy living, volunteering, reading, watching movies, listening to music.

No comments yet.

Leave a comment

Your email address will not be published.