I’ve just created a new website and am ready to switch from an my current webserver to a new webserver.
The current webserver will be renamed www2
The new webserver will be known as www
I want to redirect all traffic from www2 to www except for one directory. My directory structure looks like this:
/var
/www
/html
index.html
page2.html
/orange
index.html
...
/archive
index.html
important-page1.html
important-page2.html
/turquoise
index.html
...
I would like to redirect everything to the equivalent www page
e.g. www2.mydomain.com/orange/index.html -> www.mydomain.com/orange/index.html
www2.mydomain.com/turquoise/index.html -> www.mydomain.com/turquoise/index.html
EXCEPT for the /archive folder. I would like users requesting :
www2.mydomain.com/archive/important-page1.html to view the page on www2 and not be redirected.
Do I use mod_rewrite or mod_redirect? And can I set this up in httpd.conf?
Thanks
Yes, you would need mod_rewrite.
Try:
Note: The 301 in
R=301is a permanent redirect, you’ll need to change it to 302 if you want it to be temporary.