Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-05-2006, 08:24 AM   PM User | #1
Hw2k
New to the CF scene

 
Join Date: Aug 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Hw2k is an unknown quantity at this point
Question apache - root folder and virtual folders etc

Lets say I have this structure on my server

www.mysite.com (root)
www.mysite.com/home/ (what i want as home)
www.mysite.com/otherpage/ (i want this to stay here)

Now, what I want to do is to set the root folder to /home/, while still having access to /otherpage/ at the same adress, and without having to write special rules for every folder and file in the root folder.

Any ideas?
Hw2k is offline   Reply With Quote
Old 09-05-2006, 09:06 PM   PM User | #2
myriad360
New Coder

 
Join Date: Mar 2006
Posts: 69
Thanks: 0
Thanked 0 Times in 0 Posts
myriad360 is an unknown quantity at this point
Hmm, tough...

The only thing I can think of right now is to have the index.html auto-forward (with like Flash or whatever you like) to the 'home' directory. So truely your root directory is still www.mysite.com , but anything asking for this root folder, www.mysite.com , or www.mysite.com.index.html will get forwarded to www.mysite.com/home , and you can put other pages in the root that will not do this, as well as folders and files that behave like normal.

I dunno though, I think there is another better way. I know when you tell PHP, for example, to write to a file in say www.mysite.com/orders , you would write the link from www.mysite.com/home as '<a href="../orders/orders.txt">, and even if the root was www.mysite.com/home (literally in Apache code as C:\apache\htdocs\home or whatever, as you know), PHP would still go up whatever level you want in the OS and back down to the folder 'orders', in this case. Without any regard to permissions.

Correct me if I am wrong! But as I have found this to be true, then there must be a work around. As you know, this method of linking in PHP doesn't work in regular HTML; you could write a link "../../../../../../" ../ forever in HTML, and you would still only end up in the root folder. But in PHP it does matter, you can end up anywhere.

Alright, just ranting and thinking. I will keep think about it, hope there is a solution for you!
myriad360 is offline   Reply With Quote
Old 09-06-2006, 09:52 PM   PM User | #3
schleppel
Regular Coder

 
Join Date: Oct 2004
Posts: 330
Thanks: 0
Thanked 13 Times in 13 Posts
schleppel is an unknown quantity at this point
As long as you have access to the server configuration, you could set the document root to /home and use an Alias for /otherpage. If you have multiple domains and only want it to effect one, you can put the alias inside the domains <VirtualHost> block.


Or if you only have .htaccess files you could use mod_rewrite:
Code:
Options +FollowSymLinks

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^home(/(.*))?$ /$2 [R=301,L]

RewriteRule !^(home|otherpage)(/.*)?$ /home%{REQUEST_URI} [QSA,L]
schleppel is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:41 AM.


Advertisement
Log in to turn off these ads.