# htaccess redirect question??



## wicky (Jun 25, 2008)

I want to redirect an alternative url to a folder in a subdomain of my main site.

Example:

Somebody types: *www.productname.com*
I want to redirect them to: *www.products.maindomain.com/product_01*

If possible, I would like this to be masked, so the url in the address bar would still show: www.productname.com.

Can anybody help?


----------



## simbalala (Jun 25, 2008)

You probably want to do frame forwarding not a redirect.


```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

<html>
<head>
<title>hello</title>
<meta name="keywords" content="hello" />
<meta name="description" content="hello" />
</head>
<frameset rows="100%">
<frame src="http://yoursite.com/thedesiredpage" title="hello" frameborder="0" noresize="noresize"/>
<noframes>
<body>
<h1>hello</h1>
<p><a href="http://yoursite/thedesiredpage">http://yoursite.com/</a></p>
</body>
</noframes>
</frameset>
</html>
```

Thats one way to do it and simple. You can achieve the same thing through http redirects in .htaccess but it can get pretty complicated.


----------



## wicky (Jun 25, 2008)

Thanks, but I already know how to do it in HTML (and at nameserver, dns level, etc,).  It's the htaccess that I'm interested in knowing about.

If the masking makes it too complicated, can you break it down into redirect and then the masking?

It's the redirect that I'm most interested in.....

Somebody types: *www.productname.com*
I want to redirect them to: *www.products.maindomain.com/product_01*


----------



## Captain Code (Jun 25, 2008)

```
Redirect 301 / www.products.maindomain.com/product_01
```


----------



## wicky (Jun 29, 2008)

Thanks, but I'm a bit confused. Does this require something additional?
How does the browser distinguish between the main domain and the sub-domain?

I still want all traffic for maindomain.com to reach the maindomain. Surely this will redirect ALL traffic to www.products.maindomain.com/product_01 and completely bypass maindomain.com?

I've tried the following but neither seem to work...
Redirect 301 productname.com http://productname.maindomain.com
Redirect 301 productname.com http://www.products.maindomain.com/product_01

Either would be acceptable for now.

Thanks


----------



## Captain Code (Jun 29, 2008)

This is on the server so the browser doesn't care.  It'll receive the http 301 code which says redirect to this other URL.  You would put this .htaccess file in your html root for that domain and you have to have htaccess files enabled in your httpd.conf apache config file.


----------



## wicky (Jun 30, 2008)

The httpd.conf is set up correctly.

The root for the alternative domain is also the root for the main domain (as far as the DNS is concerned), so because it's the main root, when I add ...
*Redirect 301 / www.products.maindomain.com/product_01*
... everything redirects (including maindomain.com).

Can we use a simpler example while I get my head around the issue:
newdomain.com -> newdomain.maindomain.com

I thought this would be:
Redirect 301 newdomain.com http://newdomain.maindomain.com
but that doesn't work!?


Thanks for you patience


----------

