views:

478

answers:

2

Hello all,

Two things:

Firstly - I have version 2 of a website located in a folder named v2, and I want to redirect any traffic that is NOT a child of the v2 folder, to www.example.com/v2

The old site located in the root was created in iWeb and has a LOT of subfolders and sub-subfolders.

So:

www.example.com/v2 = New site

www.example.com/Page.html

www.example.com/category/Page.html

ww.example.com/category/subcategory/Page.html = All generic examples of what I need to redirect.

Secondly, and I don't know if this is possible, I want to hide /v2/ in the URL, so that visitors will just see www.example.com/page even though they are actually on www.example.com/v2/page

Links are hardcoded to the v2 folder, like so <a href="v2/contact.html">

Any help is MOST appreciated. I've spent hours trying to figure this out, but I'm only just learning about htaccess and regular expressions, and am totally confused.

Thanks so much!

A: 

rewrite everything by including v2 before it .

RewriteRule ^(.*)$ v2/$1 [L] 

www.example.com/Page.html should now be processed as /v2/Page.html

You should not include v2/ in the url being sent to the user.

it would then become v2/v2/

The Edifier
Thanks for your answer! I can see how that would work. I'm sorry that I haven't been clearer in my question - what I actually need to do is redirect anything that is not a child of the v2/ folder, TO the v2/ folder (www.example.com/v2) Regardless of the page on the old site (contact, products, about, etc.), I want them all to just redirect to the root of the v2/ folder. Because of all the subfolders on the old site, I need to figure out the regex for: SELECT everything IF v2 is NOT in the url, then Redirect (to use very un-techy speak) :) Thanks for answering!
KiwiCoder
+1  A: 
RewriteCond %{REQUEST_URI} !^v2/
RewriteRule ^(.*)$ v2/$1 [L] 
The Edifier
Thank you very much! This really, really helped me! I appreciate it a lot!
KiwiCoder