SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot marcoBR's Avatar
    Join Date
    Jun 2002
    Location
    Brazil
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Apache - Virtual Directory Structure

    Hello!

    I'm using this apache config to creating a virtual directory structure:

    Code:
    <VirtualHost myhost> 
       ServerAdmin webmaster@myhost 
       ServerName  yourhost 
       DocumentRoot "/my/web/path/site.php" 
    </VirtualHost>
    All requests to myhost is forced to execute site.php script ... it's working properly, but the problem is when i make requests to real directories on relative html paths, eg: /images;/includes;/cgi-bin;etc, it doesn't find this directories.

    Is there any mod_rewrite rule, cond or another solutions to resolve this problem???


    Kindest Regards,

    marcoBR

  2. #2
    SitePoint Member valkaryn's Avatar
    Join Date
    Aug 2001
    Location
    Los Angeles, California
    Posts
    15
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you declaring a php file as the DocumentRoot or is that a directory?

    If it's a file, why for the love of mike would you do that? It's an interesting concept but it seems to already be making your life miserable. But if it's really what you want to do, I would be very interested in the the logic behind it.


    You should be able to use Alias directive to get to your regular directories

    Alias /images/ /path/to/my/images
    "Decisions should be made in the space of seven breaths."
    Karyn Ulriksen
    Valkaryn Internet Group
    http://www.valkaryn.net

  3. #3
    SitePoint Zealot marcoBR's Avatar
    Join Date
    Jun 2002
    Location
    Brazil
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks valkary

    My site.php script parse and execute a mysql query based on the REQUEST_URI request, eg:

    http://myhost/soccer/article/worldcup/2/

    Did you understand now???


    Regards,

    marcoBR

  4. #4
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you set your document root to the path of a file you'll never be able to get it to go anywhere else but that file, the document root should be a directory.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  5. #5
    morphine for a wooden leg randem's Avatar
    Join Date
    Jun 2002
    Location
    .chicago.il.us
    Posts
    957
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By mapping the root to a file, you are pushing all subsequent requests through that file (script).

    One possible suggestion, though a bit drawn-out and difficult, might be to check for ^/cgi-bin/(.+) in $REQUEST_URI and then call the file from within the script, perhaps using system(). Or for /images, read in the image file and write it to the browser with the correct content-type. This sounds like more work than it's worth, however.

    Personally, I think I would take the somewhat lengthier (than current) road, and create individual files for the root documents (eg: soccer) and then in .htaccess set up mappings such as:
    <Files soccer>
    ForceType application/x-httpd-php
    </Files>


    Then, rename site.php to index.php. From there, make each file parse the remainder of the REQUEST_URI for the appropriate action. Or for that matter, have all the files be something as simple as:
    <?php
    require('index.php');
    ?>


Bookmarks

Posting Permissions

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