Forum Moderators: phranque

Message Too Old, No Replies

how do i redirect my subdomain to a sub directory

subdomain redirect setup

         

bradleyanderson

7:38 am on Mar 24, 2005 (gmt 0)

10+ Year Member



Hello! I'd like to direct a recent subdomain that I've made so that it displays subdomain.mydomain.com but reads the files from my web server that are residing in a directory mydomain/subdomain
I have made some pages and put the files in the subdirectory, and pointed the subdomain to look for files in that directory.
The problem is in the linking. I am using Dreamweaver MX and my links have always been from the root root/folder/file format. If I open the page directly from mydomain.com/subdomain/file it works and all the links work. But when I open the page from the subdomain it automatically assumes to look for the next link from the sudomain/mydomain.com/subdomain/file and the links are broken as there is no such file in that location.
I realize that I can rewrite all of my links to be [subdomain.mydomain.com...] and that will fix it, but is there a simpler solution to this?

sonjay

1:12 pm on Mar 24, 2005 (gmt 0)

10+ Year Member



You need to define the subdomain site as a whole separate site in Dreamweaver, with your subdomain directory defined as the document root of the site. I too prefer to use site-root-relative links in Dreamweaver, so I run into this issue whenever I need to work with a subdomain. The easiest way to get your head around it, IMO, is to forget all about the fact that you have mydomain.com -- just approach it as is you're setting up a whole new site called subdomain.mydomain.com (which in fact you are).

If you use DW's templates, your subdomain site will need its own templates in its own Templates folder. It will need its own images folders and its own css stylesheet. If you want the subdomain site and the main domain site to link to each other, use full http:// URLs for those links, because you are, in effect, linking to a whole separate site. Don't use any links from the main site to /subdomain/page.html, because then your site-root-relative links wouldn't work in your subdomain site.

Just to be safe, you could set up a redirect such that if someone goes to mydomain.com/subdomain, they will automatically be redirected to subdomain.mydomain.com. That will ensure that your subdomain site will always be served up by Apache as a stand-alone site, thus keeping your site-root-relative links correct.