views:

29

answers:

2

I just rebuilt a site that is currently located at

http://domainnamehere.com/v2

The existing site is located at

http://domainnamehere.com/

I need to set up a redirect so that when someone goes to the old site, it redirects to the new site. I did this on the htaccess file:

Redirect /index.html http://domainnamehere.com/v2/

But this only redirects the homepage, not the rest of the site. I also have another directory that is linked to a separate domain. The above htaccess code redirects http://anotherdomain.com to http://domainnamehere.com/v2. I do not want it to redirect other domain names. THe reason it is redirecting the other domain name is because the files are located in a directory on domainnamehere.com. I hope that makes sense!

If someone goes to http://domainnamehere.com/somethinghere I also want it to redirect to the 404 error page that would be located at http://domainnamehere.com/v2/somethinghere

Basically, I need proper htaccess code for this situation!

A: 

This should forward {whatever is after you slash} to /v2/{whatever is after you slash}

RewriteCond %{HTTP:Host} ^domainnamehere\.com$
RewriteRule /(.*) domainnamehere\.com/v2/$1

EDIT: this is for isapi rewrite, but the syntax is similar if you are using mod_rewrite.

jfrobishow
This led to an error (of course i replaced domainhere with proper domain)RewriteCond %{HTTP:Host} ^domainhere.com$ RewriteRule /(.*) domainhere.com/v2/$1
JCHASE11
500 internal server error to be exact
JCHASE11
thanks for the update, but still no luck:ForbiddenYou don't have permission to access / on this server.
JCHASE11
I am confused, since the answer was accepted - did you resolve the issue or do you need more assistance?
jfrobishow
I am good, thanks, the below answer solved all my issues
JCHASE11
+2  A: 
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domainnamehere\.com [NC]
RewriteRule ^(.*)$ http://%{HTTP_HOST}/v2/$1 [R=301,L]

Note: jfrobishow technically answered this first, this is just a fix.

Edit: Added optional www.

William