Redirect with an exception

6,505

Simply like this:

RedirectMatch ^/olduser/(?!exception/).* http://newuser.domain.com/

Instead of:

Redirect permanent /olduser/ http://newuser.domain.com/

Will redirect all /olduser request exept pattern matching /olduser/exception/ to your new domain.

Share:
6,505

Related videos on Youtube

senseiwa
Author by

senseiwa

Updated on September 18, 2022

Comments

  • senseiwa
    senseiwa almost 2 years

    I think this is easy but I am afraid I cannot solve this all by myself.

    I have moved a website to another domain, and I've set up some permanent redirections. However, I'd like to preserve one URL from any rewrite. Right now my configuration is like this:

    Redirect permanent /olduser/exception/ ???
    Redirect permanent /olduser/dir/ http://newuser.domain.com/a.html
    Redirect permanent /olduser/other/ http://newuser.domain.com/q.html
    Redirect permanent /olduser/other/sub/ http://newuser.domain.com/t/some.html
    Redirect permanent /olduser/ http://newuser.domain.com/
    

    Of course the first line is problematic, since I am redirecting in the last line the whole subdirectory to the new domain. On the new domain I don't have privileges, as it is a static website similar to GitHub.

    Note that I cannot simply use a rewrite rule, as the old directories don't correspond to new files/dirs. Or better, I cannot see how I can do this :)

    How can I make the /olduser/exception/ work on the old server, without affecting the other rules?

    Thanks!