homepage Welcome to WebmasterWorld Guest from 54.227.12.4
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

    
Subdomains/canonicals...
Best solution outside dedicated IPs?
mivox




msg:657776
 7:08 pm on Jun 11, 2001 (gmt 0)

I'm looking at building a site that would be entirely based on subdomain "departments", and need to find a good solution for implementing the subdomains... that wouldn't require paying for a static IP for each subdomain.

My host currently offers unlimited subdomains with their accounts, but it runs through some funky frames system which totally kills any possible SEO... I've seen scripts that work with ssi and/or meta refresh tags... both bad options.

How are other people implementing subdomains on their sites? (Hopefully paynt will see this thread... ;) ) I can have domain wildcards turned on for my account, if necessary.

 

agerhart




msg:657777
 7:22 pm on Jun 11, 2001 (gmt 0)

this is definitely a place for Paynt to step in......this is her specialty

paynt




msg:657778
 7:46 pm on Jun 11, 2001 (gmt 0)

mivox,

See sticky mail.

mivox




msg:657779
 8:05 pm on Jun 11, 2001 (gmt 0)

Thanks paynt!

Anyone else? The wider range of options I have to start with, the better! :)

agerhart




msg:657780
 8:15 pm on Jun 11, 2001 (gmt 0)

I am doing a site as we speak with a bunch of subdomains, and what I am trying to do is be as clean and specific as possible.

I try to keep everything super-organized, so that the different themes and sub-themes stay seperate and this is noticable by the SE

mivox




msg:657781
 9:00 pm on Jun 11, 2001 (gmt 0)

Ah... the content organization won't be a problem... I'm just trying to figure out how to execute the actual subdomain redirection.

Seems like mod_rewrite should be able to do it, but I haven't found a ready-written solution yet (found two that seem to be "close but not quite"), and I certainly don't know how to write mod_rewrite parameters/conditions/rules/whatever-you-call-them myself... :)

agerhart




msg:657782
 9:03 pm on Jun 11, 2001 (gmt 0)

Mivox,

I have to say, at the risk of sounding foolish, that I don't know what 'mod_rewrite' is, or what it does.

Could someone explain this to me? What is the use of this?......benefits? When do you use it?

Thanks in advance

mivox




msg:657783
 9:13 pm on Jun 11, 2001 (gmt 0)

mod_rewrite is an apache server module that allows the rewriting of URLs based on various user-defined rules (I don't understand it well enough to explain it better than that... sorry!). For instance, I think it could be given rules that would invisibly rewrite "subdomain.mysite.com" so that it redirected to "mysite.com/subdomain/index.html"...

But it's not easy to understand or write for if you're a beginner like I am, so I'm hoping some mod_rewrite genius will come along and give me the answer. ;)

sugarkane




msg:657784
 9:32 pm on Jun 11, 2001 (gmt 0)

mivox, do you have access to the server configuration files? mod_rewrite can probably be made to work (I'm no expert) but setting up named virtual hosts lets you have other frills like independant log files etc

mivox




msg:657785
 9:41 pm on Jun 11, 2001 (gmt 0)

Well, since all the subdomains/canonicals would be sections of one site, I don't think I'd want to have separate logs for them... but AFAIK, I have access to everything in my account's root directory, and don't have access to anything beyond that.

littleman




msg:657786
 1:39 am on Jun 12, 2001 (gmt 0)

If the domain is wildcarded than it is very simple to use name-based server hosting with apache. Al it takes is something like this added to the httpd.conf file:

NameVirtualHost 111.222.111.222

<VirtualHost 111.222.111.222>
DocumentRoot /path/to/sub1.domain.com/
ServerName sub1.domain.com
CustomLog /path/to/sub1.domain.com.log
</VirtualHost>

<VirtualHost 111.222.111.222>
DocumentRoot /path/to/sub2.domain.com/
ServerName sub2.domain.com
CustomLog /path/to/sub2.domain.com.log
</VirtualHost>
and so on.

The above example uses separate logs, but they all could go into one central log if you wanted.

If your web hosting company isn't run by nice people you could try this mod_rewrite solution
A mod_rewrite approach:

1) Put this in your .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^[^.]+\.domain\.com$
RewriteRule ^(.+)$ %{HTTP_HOST}$1 [C]
RewriteRule ^([^.]+)\.domain\.com(.*) $1/$2 [L]

2) You need to have your domain wildcarded, So www.domanin.com and xyz.domain.com will go to the same folder.

3) You need to put an overriding .htaccess in your subdomain folders.
So if you are going to use products.domain.com you need to have /path/to/domain/products use it's own .htaccess folder with an overwriting mod_rewrite command. It could be as simple as "RewriteEngine off" at the top of an otherwise blank page.

That should be it.
So now blahh.domain.com/123.html will be internally directed to /path/to/domain/blahh(the sub-folder)/123.html

The second approach is more resource intensive, so you should try the first approach if your hosting company makes it possible.

mivox




msg:657787
 5:48 am on Jun 12, 2001 (gmt 0)

Ahh, littleman, you are now one of my minor dieties... who'd think a guy in a pea-pod suit would be such a fountain of knowledge? (Should I use a statuette of the Jolly Green Giant on the altar? hmm...)

I know I can get wildcards turned on. Whether or not I can talk them into editing the httpd.conf file for me is yet to be seen... but if I know specifically what to ask for, my odds are probably better. Thanks!

alexjc




msg:657788
 10:54 pm on Aug 27, 2001 (gmt 0)

Sorry for bringing this thread up again, but it's the exact problem I've been confronted with. I should have known where to look first!
** slaps forehead **

Anyway, mivox:
I think when you have one Virtual Host setup in apache, it becomes the default. When you have multiple VH sections, apache uses the first as default. Then, all requests to unknown subdomains (not handled explicitely in httpd.conf) will be sent to it.

The problem is to setup the DNS records in the first place. You need to be able to add CNAME records, or at least you get them to do it for you.

littleman:
I found that gem in the apache manual too, and after experimenting with it for a few minutes, i've found a few problems...

1) Turning RewriteEngine Off in the subdomain folders gives me a 403 Forbidden error.
2) Folders in the main domain don't work anymore! (403 also)
3) I get a "Bad Rrequest" for accessing the subdomains with everything you mentioned setup right.

Another issue that may need considering: banning people from accessing [domain.com...] directly. I would show you my code for this, but I'll wait until everything is working perfectly ;)

mivox




msg:657789
 11:00 pm on Aug 27, 2001 (gmt 0)

I'm looking forward to hearing your final configuration, alexjc... although right now, I'm considering just handling the site in question on a different host that offers true subdomains as a regular account option.

littleman




msg:657790
 11:36 pm on Aug 27, 2001 (gmt 0)

I just tried it again, and it still works for me. I bet you are violating something in the httpd.conf file. I think you need to have 'Options All'
& 'AllowOverride All' set for it to work.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved