SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    Apache directories

    Hey,
    How can I set-up Apache to have something like a virtual directory? Like http://localhost/clanmod
    is really D:\gamezone\Half-Life\cstrike\addons\clanmod but my DocumentRoot is C:\www\root.

    Anyone know how to do this?

    Thanks

  2. #2
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    this is a question about Apache only,
    so next time please put it into the brand new forum "Configuring Apache"...check my sig!

    Well,
    just because you are here let me examine your question

    Your question can be answered based on this scenario:
    http://httpd.apache.org/docs/urlmapping.html#outside

    So you could do:

    Alias /clanmod "D:\gamezone\Half-Life\cstrike\addons\clanmod"

    Please note that the Alias directive cannot be put inside .htaccess,
    http://httpd.apache.org/docs/mod/mod_alias.html#alias

    Also check the advices here
    http://httpd.apache.org/docs/urlmapping.html#outside


    I tested on my pc locally and it works...



    pippo
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  3. #3
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Thanks for that, I would have posted in the Apache forum but I didn't know it existed

    While it's here though, do you know if I can make it so outside users can't use it? Like I want to edit some files in the directory with a PHP script but I don't want outside users to have access to it.

    Any ideas on this?

    Thanks

  4. #4
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's not clear to me what you exactly want to do,
    but with php it's possible for you to access files outside the Apache Document Root ( if you have the right permissions to do that ).

    >>do you know if I can make it so outside
    >>users can't use it? Like I want to edit
    >>some files in the directory with a PHP
    >>script but I don't want outside users
    >>to have access to it.
    Not sure this is what you want,
    but for example you could do:

    .htaccess
    Code:
    <FilesMatch "\.inc$">
    order allow,deny
    deny from all
    </FilesMatch>
    This will prevent file with .inc extension for being viewed externally.
    But inside your scripts you can always do:
    PHP Code:
    include 'myfile.inc';
    //etc 
    For the same concept it's possible to deny accesses to a directory from "outside" such as:
    /clanmod/.htaccess
    Code:
    order allow,deny
    deny from all
    but from your scripts you can:
    /myfile.php
    PHP Code:
    include "clanmod/somefile.someext"
    //or
    $fp fopen"clanmod/somefile.someext""w" );
    //put some info inside the file
    fclose$fp );
    //
    // Typing somesite.com/clanmod/somefile.someext
    // will produce a Forbidden error
    // 
    So basically it's possible to access the directory clanmod from your scripts but not from the web (browser).

    As you can see, there are many things that you can do.
    I have not take in consideration using rewrite rules,
    which are my favourites and that I love shameless, because most often people do no have access to them .

    If you are more specific (for me at least ), it could be possible to give a more specific and well dedicated answer for your needs.

    Hope This Helps!



    pippo
    Last edited by pippo; Nov 2, 2002 at 08:17.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Ta, but after changing my mind I've decided that I don't want to block access.

    Thanks for your help on this

  6. #6
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    DJ, good job using clanmod, clanmod rocks
    I am a.k.a. Harlaugur, CM team
    - website

  7. #7
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And now I have a question for u pippo, about locking directorys.

    ok, now how do i access a directory on my webserver, say i host my website in
    C:\wwwroot\
    and i wan't to give ppl access to
    C:\wwwroot\dl\
    but when i go in there there comes this error


    Forbidden
    You don't have permission to access /dl/ on this server.

    --------------------------------------------------------------------------------

    Apache/2.0.43 Server at localhost Port 80
    And sice i am the web server i should be able to control it. From another thread i read i should use .htaccess but in the manual says this

    In general, you should never use .htaccess files unless you don't have access to the main server configuration file.
    So I was wondering, how would i set it so all users can view this folders items and dl them, also, could I just allow some users to access this directory

    A answear would be very helpful!
    - website

  8. #8
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    You can use a .htaccess file to control who has access to it but I'm not sure how you would let users browse the directory

    Good luck though


    PS. ClanMod rocks

  9. #9
    FreeBSD The Power to Serve silver trophy pippo's Avatar
    Join Date
    Jul 2001
    Location
    Italy
    Posts
    4,514
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you want only some people to be able to access a particular directory I would suggest to use user authentication:
    http://httpd.apache.org/docs-2.0/howto/auth.html

    So,
    httpd.conf
    Code:
    <Directory "c:\wwwroot\dl">
     AuthType Basic
     AuthName "Restricted DL Area"
     AuthUserFile "c:\some\path\to\password\file\passwords"
     require valid-user
    </Directory>
    I put "require valid-user" instead of "require user pippo paperino" because when you'll add a new user you'll have to change httpd.conf and so you'll have to reboot the http server.
    http://httpd.apache.org/docs-2.0/mod/core.html#require

    It's possible to create an .htaccess file inside the directory c:\wwwroot\dl too.

    I would keep the password file outside the document root.

    To create the password file:
    htpasswd.exe -c c:\some\path\to\password\file\passwords pippo
    pippo is an user name...

    That command creates the file too.

    To add another user:
    htpasswd.exe c:\some\path\to\password\file\passwords paperino

    More info about htpasswd utility:
    http://httpd.apache.org/docs-2.0/programs/htpasswd.html

    So when an user will want to access yoursite.somewhere/dl directory he will be prompted to insert user+password.


    It's possible to restrict accesses to people by their ip too.
    The link I provided take in consideration that too and more...

    Typically before posting something I test it,
    actually I can't.



    pippo

    p.s.
    About .htaccess vs httpd.conf,
    there are some considerations to do.

    Preamble)
    The advice of the manual is right...obviously!

    1st)
    Perfomance,
    putting directives inside httpd.conf is a bit faster.
    For example on an server I owned I disabled apache to look at .htaccess.
    I do not know how faster in terms of time it is,
    I admit it's a concept that one day or another I will check in deep.

    2nd)
    Not all directives can be put inside .htaccess.

    3rd)
    Changes to the httpd.conf require you to restart the http server.

    4th)
    Most of the people will have to access to .htaccess only,
    that's why most example refer to it only.

    5th)
    Independently by the fact of the perfomance it's right to use .htaccess in some circumstance,
    even if you could modify httpd.conf.
    By using .htaccess it's more easy to maintain your website,
    you do not need to restart the server.

    6th)
    .htaccess permit end-user configurations.

    7th)
    Last but not least,
    these are my humble thoughts only....
    Last edited by pippo; Nov 6, 2002 at 01:12.
    Mr Andrea
    Former Hosting Team Advisor
    Former Advisor of '03

  10. #10
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i got it I think, apache dosn't start up right now but i know what to do
    1 thing, htpasswd, how the f*** does it work, ok I have some lines of some sorce stuff but how accually does it work, do I make a shortcut and add stuff to the command line or do I just double click it and then it comes (didn't work) or just what?

    I apreciate your help!
    - website


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
  •