Welcome to MobyThreads.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in
All support for the MobyThreads Threaded phpBB MOD can now be found on welsolutions at this forum

Folders and subdomains

 
   Web Hosting and Web Master Forums (Home) -> Apache RSS
Next:  Opinion Please  
Author Message
divx

External


Since: Jan 11, 2005
Posts: 2



(Msg. 1) Posted: Tue Jan 11, 2005 9:35 am
Post subject: Folders and subdomains
Archived from groups: alt>apache>configuration (more info?)

Hi all,
I'd like to have sometingh working like this:
if a user call a subdomain ie test.mydomain.com I'd like apache to
internally redirect to mydomain.com/test... without setting each redirecti
in htaccess.

so
whatever.mydomain.com should redirecto to mydomain.com/whatever

If "/whatever" folder doesn't exist it should go to mydomain.com...

Any help?

Thank You Smile

Ivan

 >> Stay informed about: Folders and subdomains 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 2) Posted: Tue Jan 11, 2005 9:35 am
Post subject: Re: Folders and subdomains [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2005-01-11, Ivan <divx RemoveThis @fastwebnet.it> wrote:
 > if a user call a subdomain ie test.mydomain.com I'd like apache to
 > internally redirect to mydomain.com/test...

<VirtalHost *>
  ServerName test.mydomain.com
<font color=purple>  RedirectPermanent <a style='text-decoration: underline;' href="http://mydomain.com/test</font" target="_blank">http://mydomain.com/test</font</a>>
</VirtualHost>

 > whatever.mydomain.com should redirecto to mydomain.com/whatever
 > If "/whatever" folder doesn't exist it should go to mydomain.com...

Then a CGI script looks better suited for this.

Davide

--
It's ten o'clock. Do you know where your source code is?<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: Folders and subdomains 
Back to top
Login to vote
divx

External


Since: Jan 11, 2005
Posts: 2



(Msg. 3) Posted: Tue Jan 11, 2005 9:35 am
Post subject: Re: Folders and subdomains [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Davide Bianchi" <davideyeahsure.RemoveThis@onlyforfun.net> ha scritto nel messaggio
news:slrncu7k6a.2l8.davideyeahsure@fogg.onlyforfun.net...
 > On 2005-01-11, Ivan <divx.RemoveThis@fastwebnet.it> wrote:
 >
 > <VirtalHost *>
 > ServerName test.mydomain.com
<font color=purple> > RedirectPermanent <a style='text-decoration: underline;' href="http://mydomain.com/test</font" target="_blank">http://mydomain.com/test</font</a>>
 > </VirtualHost>
 >
  >> whatever.mydomain.com should redirecto to mydomain.com/whatever

Thank's for your fast answer.

Don't you know if there is a way I can wildcard (*) also the subdomain and
the folder... something like

<VirtalHost *>
ServerName *.mydomain.com
RedirectPermanent <a style='text-decoration: underline;' href="http://mydomain.com/" target="_blank">http://mydomain.com/</a>*
</VirtualHost>

So that whatever the users writes in the subfolder part, apache will look
for a subfolder with that name?<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Folders and subdomains 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 4) Posted: Tue Jan 11, 2005 9:35 am
Post subject: Re: Folders and subdomains [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2005-01-11, Ivan <divx DeleteThis @fastwebnet.it> wrote:
 > Don't you know if there is a way I can wildcard (*) also the subdomain and
 > the folder... something like

You could do that using mod_rewrite, the problem is that if the
subdomain doesn't exist you'll get a 404 error. This is the reason I
suggested a cgi script of some sort. In the cgi you can do a
"the directory exists? yes->show it, otherwise->redirect to..."

Davide

--
Managers are those lusers who can tell you what to do and you kinda[3] have
to listen.
[3] I mean "kinda" in the "not really, in fact, not at all" mode.
--Chris Saunderson<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Folders and subdomains 
Back to top
Login to vote
user3429

External


Since: Jan 11, 2005
Posts: 4



(Msg. 5) Posted: Tue Jan 11, 2005 12:17 pm
Post subject: Re: Folders and subdomains [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

 > You could do that using mod_rewrite, the prolem is that if the
 > subdomain doesn't exist you'll get a 404 error.

If the sundomain does not exist you will get "host not found" or
"lookup failed" error in idea, because 404 is HTTP status code
and apache has nothing (well, almost) to do with such domains.

This can be easily solved by adding wildcard entry to BIND (or any
other dns server that supports thats -- up to you) zone file, e.g.

; SOAs etc. here
myhost.com IN A 12.34.56.78
*.myhost.com IN A 12.34.56.78

And using mod_rewrite like this: [in global config file, e.g.
/etc/apache/httpd.conf]

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*).myhost.com$
RewriteRule ^(.*)$ <a style='text-decoration: underline;' href="http://myhost.com/%1$1" target="_blank">http://myhost.com/%1$1</a> [R]

(Sorry if I have mistyped something Wink

This is much, much, much better than using <VirtualHost *> unless you
are frightened by mod_rewrite (voodoo?)<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Folders and subdomains 
Back to top
Login to vote
davideyeahsure

External


Since: Nov 03, 2003
Posts: 2907



(Msg. 6) Posted: Wed Jan 12, 2005 1:35 am
Post subject: Re: Folders and subdomains [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 2005-01-11, adomas.paltanavicius.RemoveThis@gmail.com <adomas.paltanavicius.RemoveThis@gmail.com> wrote:
 > If the sundomain does not exist you will get "host not found"

If he redirect every subdomain to a different folder, any 'inexistent'
subdomain is an inexistent subfolder, hence the 404.

Davide

--
Type cat vmlinuz > /dev/audio to hear the Voice of God.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Folders and subdomains 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Subdomains - Hi there I'd like to know how to configure Apache 1.3.29 so that when I type http://www.127.0.0.1 or http://127.0.0.1, it goes and check the /www/ folder in the documentroot. Same for http://forum.127.0.0.1 ... I'd like it to point to /forum/ folder in....

catch all + subdomains - Hi, At first: I'm not an apache administrator:) I need to make catch all function for all subdomains. For exp. http://www.somthing-dsadas.mydomain.com or dasdasds.mydomain.com should be redirect to mydomain.com. I heard that I can do a wildcard in..

Vhost and subdomains - Hi all, I have the following setup for a domain using Vhosts: <VirtualHost 65.39.131.101> User caspringlo Group users ServerName springloaded.ca ServerPath /springloaded.ca Setenv VLOG /home/caspringlo/logs DocumentRoot /home/caspringlo/public_ht...

SubDomains and a RAQ4 - Another sub-domain question. This may not be the proper place, but I can't seem to get an answer from Sun on this. I have a Cobalt Raq 4 with all current patches, but default installs of software. I want to create subdomains that are controlled by one...

Help: Multiple subdomains on same site. - I want to host "any" subdomain on the same pages/ same site. Like *.somedomain.com so that any subdomain of "somedomain.com" will be directed to the same pages on the same site but still with that subdomain.somedomain.com in the ...
   Web Hosting and Web Master Forums (Home) -> Apache All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]