Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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?

  • #2
    New Coder
    Join Date
    Mar 2006
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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!

  • #3
    Regular Coder
    Join Date
    Oct 2004
    Posts
    330
    Thanks
    0
    Thanked 13 Times in 13 Posts
    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]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •