301 htaccess

Status
Not open for further replies.

eliquid

Serpwoo.com
May 10, 2007
7,207
205
63
A/B Testing
somehow, this is more complicated then I thought...

i got this subdomain i want to 301 to my main domain


i.e. sub2.domain.com needs to 301 to domain.com


however, I no longer have the folder/subdomain sub2

lots of answers say " put a htaccess file in sub2 and 301 that way " but i no longer have that folder any more and do not want to make it. Why? because I have several of these folders/subdomains like this no longer on the server and I would not want to recreate all of them just to put one file in them and have them on the server forever just for a redirect.

is there a line of code I can put in the root htaccess to redirect all sub2.domain.com to domain.com for a 301 that actually works.

I cant seem to get anything to work.
 


that might be the problem, I no longer have the subdomain or the folder it created and did put the htaccess code in the root of the main domain, which by the way is where it is redirecting per my first post, thus causing the never ending loop.
 
Should be able to do it without recreating the sub-domain, just use a rewrite...

Code:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^sub2\.domain\.com [OR]
RewriteCond %{HTTP_HOST} ^www\.sub2\.domain\.com
RewriteRule ^(.*)$ http://www.domain.com/ [R=301,L]
 
Status
Not open for further replies.