logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Sub Directories
Author
xad001x0w



Joined: 18 Sep 2006
Posts: 8
Location: UK

PostPosted: Mon 18 Sep '06 18:35    Post subject: Sub Directories Reply with quote

Hi, I currently have a windows 2003 server, running apache 2.0.58 with php 4.4.2. Currently our directory structure is a follows:

../htdocs/www.domain.com/*website files*
../htdocs/sub.domain.com/*website files*
../htdocs/sub2.domain.com/*website files*

however, I would like it to be more in the order of:

../htdocs/domain.com/*website files*
../htdocs/domain.com/sub/*website files*
../htdocs/domain.com/sub1/*website files*

I understand that this can be done using htaccess files, but I am unsure of how to exactly so would really like someone to just go through it with me. Also on an old hosting account I had (am now on dedicated server) if you had a subfolder in your site you could access it via at www.domain.com/subfolder OR subfolder.domain.com So if that is possible just by creating a new subfolder in the domain folder i would love to be able to do that.
Many thanks!
Back to top
DeliriumServers



Joined: 17 Jun 2006
Posts: 54
Location: H Town

PostPosted: Mon 18 Sep '06 22:23    Post subject: Reply with quote

I use mod_vd to do this. I combine it with a mod_rewrite rule so that the www and non www version resolve to the same folder. At my request mod_vd has been compiled and it is available on the downloads page.

Be warned that mod_vd is designed for speed and ease, so there aren't a whole lot of options

-delirium
Back to top
xad001x0w



Joined: 18 Sep 2006
Posts: 8
Location: UK

PostPosted: Mon 18 Sep '06 22:58    Post subject: Reply with quote

Any chance you could show me an example of this?

Cheers

EDIT:
Not sure if i mentioned this but the system has to be quite dynamic. as we are running 2 or 3 websites from our server (static IP). So basically I would like to be able to just make the folder ../htdocs/domain.com/ and for it to be accessable at www.domain.com (obviously setting up DNS and everything) and then for the sub folders to be accessable at subfolder.domain.com.

Thanks again
Back to top
DeliriumServers



Joined: 17 Jun 2006
Posts: 54
Location: H Town

PostPosted: Tue 19 Sep '06 0:39    Post subject: Reply with quote

well then, you couldn't have asked for a better module!

here is an example, more is possible, but this is how I use it

in my httpd.conf I have:


Code:
LoadModule vd_module modules/mod_vd.so
LoadModule rewrite_module modules/mod_rewrite.so

# Remove www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [R=301,L]

<IfModule vd_module>
    VdEnable on
    VdChopPrefix 0
    VdChopSuffix 0
    VdPathPrefix F:/www/webroot
</IfModule>


this way all requests to my web server have the www. stripped off so that mod_vd will process everthing correct (according to my setup)

then it will map it to a folder like this:

http://subdomain.deliriumservers.com
F:/www/webroot/com/deliriumservers/subdomain

http://www.deliriumservers.net
http://deliriumservers.net
F:/www/webroot/net/deliriumservers

so you can access stuff just like you wanted as a folder or a subdomain and it's completely dynamic

for more information on setting up mod_vd please read the instructions at
http://www.snert.com/Software/mod_vd/index.shtml


-delirium
Back to top
xad001x0w



Joined: 18 Sep 2006
Posts: 8
Location: UK

PostPosted: Wed 20 Sep '06 21:12    Post subject: Reply with quote

Great, set everything up (had to update to apache 2.2) then whacked your bit of code into httpd.conf and im sailing.
however...

1) i have co.uk TLDs so therefore they split like this: ../htdocs/uk/co/domain/sub/
Any way to make it go like this:
../htdocs/co.uk/domain/sub

2) on the 2 sites on my server www.domain.com just goes to ../htdocs/ not ../htdocs/uk/co/domain/ Any ideas?

BTW, cheers for showing me mod_vd delerium!
Back to top
DeliriumServers



Joined: 17 Jun 2006
Posts: 54
Location: H Town

PostPosted: Wed 20 Sep '06 22:07    Post subject: Reply with quote

@xad001x0w

1) I don't know of a way to do it like that... I think this would be a limitation of mod_vd since if it treated one domain like that it would confuse the others

2) could you elaborate a bit more? I'm not exactly sure what is happening to you
Back to top
xad001x0w



Joined: 18 Sep 2006
Posts: 8
Location: UK

PostPosted: Thu 21 Sep '06 1:22    Post subject: Reply with quote

Right, ok.

i have 2 sites running on my server i can get to all the subdirectories fine via sub.domain.com. However, when trying to go to www.domain.com i just end up at the apache document root. I can get to the correct location (../htdocs/com/domain/) by typing http://domain.com into the address bar (note no www) but adding the www just lands me back at the doc root. This was happening before i did all this mod_vd stuff and could therefore be related to anything (DNS, apache etc.) we have control over our DNS as we are using the DNS server that is on windows server 2003.
Back to top
DeliriumServers



Joined: 17 Jun 2006
Posts: 54
Location: H Town

PostPosted: Thu 21 Sep '06 3:45    Post subject: Reply with quote

hmm ok, well try looking at these things:

does your dns forward wildcards? *.domain.com

did you make sure to include my rewrite rule and enable mod rewrite?
(the rewrite rule will remove the www if you type it in, in order to create consistancy for mod_vd, it is also better for the search engines to have only www or only not.)

you may have the www.domain.com defined somewhere in your conf file and this may be causing strange behavior

It also appears I left out a line for my rewrite rule....... sorry, that might be the problem
it should look like this:


Code:
Options +FollowSymLinks

RewriteEngine On

# Remove www.
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1$1 [R=301,L]



-delirium
Back to top
xad001x0w



Joined: 18 Sep 2006
Posts: 8
Location: UK

PostPosted: Thu 21 Sep '06 18:00    Post subject: Reply with quote

I added the extra couple of lines and changed the DNS (added wild card) and now all works as planned - hoorah! I think thats about all for now, thanks Delirium!
Back to top
DeliriumServers



Joined: 17 Jun 2006
Posts: 54
Location: H Town

PostPosted: Thu 21 Sep '06 22:16    Post subject: Reply with quote

welcome
Back to top


Reply to topic   Topic: Sub Directories View previous topic :: View next topic
Post new topic   Forum Index -> Apache