Forum Moderators: phranque

Message Too Old, No Replies

segment of domain (example.com/subsite/) to point to document root

         

martinoleary

2:11 pm on Nov 2, 2011 (gmt 0)

10+ Year Member



Hi,

I'm working on a site for a client and I'm doing up a subsite for them. They don't want to use a subdomain.

So, there is a site called www.example.com, is it possible to create an entry in the apache config (or something!) so that if they go to www.example.com/subsite/ , that it will point the document root to a certain folder on the file system, and all links and files will be relevant from this folder etc...

The original site is done in wordpress and the new site is just php.

Any help/comments are welcome!

Thanks,
Martin.

lucy24

8:20 pm on Nov 2, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



What exactly do you mean by "subsite"? An entirely different domain name? It should make no difference where the domain physically lives, so long as the DNS is pointing to the right place. But the mechanics will depend on the server setup. Is it your own server or are you on shared hosting?

In general, things come out "cleanest" if the name structure (what the outside world sees) corresponds to the real-life structure (what the server sees). If you've got two separate domains, put them side by side on the same level.

Or do you simply mean that within www.example.com/onedirectory, everything should behave differently from all the other directories? What will the user see?

martinoleary

9:23 am on Nov 3, 2011 (gmt 0)

10+ Year Member



Hi, Thanks for your reply. I'll try and explain a little more.

Its a shared server. When I say subsite, I mean a completely different site. I would like the url www.example.com/subsite/ to act the exact same as a subdomain site e.g. subsite.example.com.

The folders structure would be side by side. for example /var/www/public/ and /var/www/subsite/ .

I would like them to act like two different domains. When the url is example.com or example.com/action/aboutus, it points to the public folder and the document root is /var/www/public/ and when the url starts with example.com/subsite/ or example.com/subsite/action/aboutus, it points to the subsite folder and the document root is /var/www/subsite/ .

I would need links within the subsite to be relative of the subsite url. if I was browsing the subsite and I was on example.com/subsite/action/aboutus and I click the home link href="/", I would need it to go to example.com/subsite/ also.

Any further comments would help me alot.

If I was up to me I'd use a subdomain :P

lucy24

6:57 pm on Nov 3, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



No kidding ;)

OK, here's the tricky part: Once you're in example.com/subsite/blahblah, how would you get out? Think of that both from the user's side and yours: if "Home" means "example.com/subsite/" then what is "example.com/" called and how do you get there?

Got a lurking suspicion this bit will be harder than everything else put together. (Or vice versa. That is, you can easily do one or the other; it's merging them that gets messy.)

:: looking vaguely around for g1, who speaks fluent Apache* ::


* I only speak RegEx. Fortunately, that takes care of about 90% of your htaccess needs. Unfortunately, we are now in the other 10%.

g1smd

8:37 am on Nov 4, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Since links are in URLs and URLs are used only on the web, not inside the server, links and therefore URLs are resolved by the browser.

To link to another page within a site link to /page or to /folder/page. To link to a different site link to example.com/page or to example.com/folder/page.

As for your specific problem you'll need to set up a folder alias in your server configuration. You can never truly have these as "two separate websites" while they both live at example.com. One of them should be on a separate domain or subdomain.