image
image

|


Go Back   macosx.com > Design, Media, Programming & Scripting > Software Programming & Web Scripting

Reply
 
Thread Tools
  #1  
Old June 25th, 2008, 07:48 AM
wicky's Avatar
play thing
 
Join Date: Jul 2002
Location: London
Posts: 354
Thanks: 0
Thanked 0 Times in 0 Posts
wicky is on a distinguished road
htaccess redirect question??

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?
__________________
#me {
Leaf Media: Design & Dev;
Liquid Layouts: Interactive Photography;
}
Reply With Quote
  #2  
Old June 25th, 2008, 09:13 AM
Registered User
 
Join Date: Jul 2005
Posts: 819
Thanks: 0
Thanked 0 Times in 0 Posts
simbalala is on a distinguished road
You probably want to do frame forwarding not a redirect.

Code:
<!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.
Reply With Quote
  #3  
Old June 25th, 2008, 09:24 AM
wicky's Avatar
play thing
 
Join Date: Jul 2002
Location: London
Posts: 354
Thanks: 0
Thanked 0 Times in 0 Posts
wicky is on a distinguished road
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
__________________
#me {
Leaf Media: Design & Dev;
Liquid Layouts: Interactive Photography;
}
Reply With Quote
  #4  
Old June 25th, 2008, 07:07 PM
Captain Code's Avatar
Moderator
 
Join Date: Aug 2001
Location: Ontario, Canada
Posts: 3,101
Thanks: 0
Thanked 0 Times in 0 Posts
Captain Code will become famous soon enough
Code:
Redirect 301 / www.products.maindomain.com/product_01
__________________
MacBook Pro 2.16GHz Core2Duo 3GB RAM, G4 1.4GHz OSX Tiger 1.25GB RAM, Dual 2GHz G5 OSX Tiger 2GB RAM (freakin shweet)
Athlon 64 Windoze XP for school work (programming) 1GB RAM
dferns@macosx.com
Reply With Quote
  #5  
Old June 29th, 2008, 02:19 PM
wicky's Avatar
play thing
 
Join Date: Jul 2002
Location: London
Posts: 354
Thanks: 0
Thanked 0 Times in 0 Posts
wicky is on a distinguished road
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
__________________
#me {
Leaf Media: Design & Dev;
Liquid Layouts: Interactive Photography;
}
Reply With Quote
  #6  
Old June 29th, 2008, 03:22 PM
Captain Code's Avatar
Moderator
 
Join Date: Aug 2001
Location: Ontario, Canada
Posts: 3,101
Thanks: 0
Thanked 0 Times in 0 Posts
Captain Code will become famous soon enough
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.
__________________
MacBook Pro 2.16GHz Core2Duo 3GB RAM, G4 1.4GHz OSX Tiger 1.25GB RAM, Dual 2GHz G5 OSX Tiger 2GB RAM (freakin shweet)
Athlon 64 Windoze XP for school work (programming) 1GB RAM
dferns@macosx.com
Reply With Quote
  #7  
Old June 30th, 2008, 05:10 AM
wicky's Avatar
play thing
 
Join Date: Jul 2002
Location: London
Posts: 354
Thanks: 0
Thanked 0 Times in 0 Posts
wicky is on a distinguished road
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
__________________
#me {
Leaf Media: Design & Dev;
Liquid Layouts: Interactive Photography;
}
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 09:00 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.