Daily Archives

30 November 2015

.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