#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    29
    Rep Power
    0

    Alias issue and 404


    Hi guys can anybody direct me.

    Platform is Windows XP sp3 - local dev environment with Apache 2.2.19

    have this in my httpd.conf

    Alias /NamadanImages "C:\Documents and Settings\Andrew Seabrook\My Documents\TheAuthor\Namadan\images"
    <Directory "C:\Documents and Settings\Andrew Seabrook\My Documents\TheAuthor\Namadan\images">
    Order allow,deny
    Allow from all
    </Directory>

    Have this in the browser address bar
    http://localhost/phpgal/NamadanImages/craymark/eagle.jpg

    getting 404 error !!!!!!

    the following file exists in file system! displaying if I type it into the browser address bar thus: file:///C:\Documents and Settings\Andrew Seabrook\My Documents\TheAuthor\Namadan\images\craymark\eagle.jpg
  2. #2
  3. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    /NamadanImages is not the same as /phpgal/NamadanImages.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    29
    Rep Power
    0
    Originally Posted by requinix
    /NamadanImages is not the same as /phpgal/NamadanImages.
    No its not, correct, but the webpage is being served from localhost/phpgal

    please spell out why this is a problem - how do I alias a filesystem directory from webpage located deeper than localhost?
  6. #4
  7. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    Originally Posted by CallMeAndy
    No its not, correct, but the webpage is being served from localhost/phpgal
    Alias only cares about the URL. Page, site, document root, none of those matter.

    Did you try just changing the alias to use "/phpgal/NamadanImages"?
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    29
    Rep Power
    0
    Originally Posted by requinix
    Alias only cares about the URL. Page, site, document root, none of those matter.

    Did you try just changing the alias to use "/phpgal/NamadanImages"?
    Well yes and thanks it works - but really cant get my head around the substitution made by apache on this.

    The actual page index.php that is found at localhost/phpgal is made up of images constructed along these lines:

    <a href="./NamadanImages/craymark/800px-DanubedeltaSulinaarm2.jpg" class="photo-link smoothbox" rel="gallery"><img src="./NamadanImages/craymark_thumbs/800px-DanubedeltaSulinaarm2.jpg" /></a>

    surely when resolved the aliases would be formed: ./phpgal/filespec/..../image.jpg

    ordinarily however if i included the phpgal part of the url it would not find the image.
    To ilustrate what I mean i just bunged a couple of images in the site root: localhost/phpgal

    I am requesting localhost/phpgal/index.php in the browser address bar

    and hard coded this at the top of the page;

    <a href="./phpgal/danube.jpg" class="photo-link smoothbox" rel="gallery"><img src="./phpgal/danube_copy.gif" /></a>

    not surprisingly it cant find that image

    yet these below it with the altered alias as per your suggestion are working
    <a href="./NamadanImages/craymark/800px-DanubedeltaSulinaarm2.jpg" class="photo-link smoothbox" rel="gallery"><img src="./NamadanImages/craymark_thumbs/800px-DanubedeltaSulinaarm2.jpg" /></a>

    What is it I am not understanding about the substitution?
  10. #6
  11. Transforming Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    14,183
    Rep Power
    9398
    What I can't get my head around is what you're confused about. Your post doesn't make any sense to me So let me throw out some information and I'll hope it helps.

    If you're in /phpgal/index.php and you put some links to "./phpgal/danube.jpg" then the browser will resolve it to "/phpgal/phpgal/danube.jpg" (note the repetition) and ship that off to Apache. Apache doesn't know anything special about that URL so it will try to serve it normally; since there is no such file there it will reply with a 404.
    If your document root was (a conveniently short) C:\www then Apache will look for C:\www\phpgal\phpgal\danube.jpg.

    If you instead link to "./NamadanImages/craymark" (the directory) then the browser will ask for "/phpgal/NamadanImages/craymark". This time Apache recognizes the "/phpgal/NamadanImages" prefix from the Alias you used, so instead of looking in the document root like it normally would it looks in whatever the Alias you gave had.
    Even though the document root is C:\www the Alias says to start looking in C:\etc\Namadan\images, thus the final file path is C:\etc\Namadan\images\craymark.
  12. #7
  13. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2005
    Posts
    29
    Rep Power
    0
    Originally Posted by requinix
    What I can't get my head around is what you're confused about. Your post doesn't make any sense to me So let me throw out some information and I'll hope it helps.

    If you're in /phpgal/index.php and you put some links to "./phpgal/danube.jpg" then the browser will resolve it to "/phpgal/phpgal/danube.jpg" (note the repetition) and ship that off to Apache. Apache doesn't know anything special about that URL so it will try to serve it normally; since there is no such file there it will reply with a 404.
    If your document root was (a conveniently short) C:\www then Apache will look for C:\www\phpgal\phpgal\danube.jpg.

    If you instead link to "./NamadanImages/craymark" (the directory) then the browser will ask for "/phpgal/NamadanImages/craymark". This time Apache recognizes the "/phpgal/NamadanImages" prefix from the Alias you used, so instead of looking in the document root like it normally would it looks in whatever the Alias you gave had.
    Even though the document root is C:\www the Alias says to start looking in C:\etc\Namadan\images, thus the final file path is C:\etc\Namadan\images\craymark.
    If I knew why I was confused confused then I wouldnt be confused anymore.

    My failure to understand though comes from the fact that I expected apache only to substitute the string: "/NamadanImages"

    so that the link "NamadanImages/craymark/danube.jpg" effectivly becomes a filespec.
    echo '<a href="C:/Documents and Settings/Andrew Seabrook/My Documents/MyWeb/phpgal/danube.jpg" class="photo-link smoothbox" rel="gallery"><img src="C:/Documents and Settings/Andrew Seabrook/My Documents/MyWeb/phpgal/danube_copy.gif" /></a>';

    which I see from later experiment is not recognised.


    And also as this string "/phpgal/NamadanImages" is not in the link I would not have expected it to attempt to substitute anything.

    I guess we are not talking about littoral string substitution, but rather a deterministic substitution (resolving), based on apaches UNDERSTANDING of URLs which is knowledge I dont have and perhaps why I made other assumptions about the substitution.

    If I still havnt got it please feel free to try and help me further, either way much appreciate your help.

    Andy

IMN logo majestic logo threadwatch logo seochat tools logo