SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast athena's Avatar
    Join Date
    Apr 2002
    Location
    Vancouver, Canada
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    problems with triggering open_dir when using URL re-writing

    I've become accustomed to using URL re-writing as a means to keep the URL tidier however I'm running up against the fact that it's forcing me to write code that triggers the open_dir restriction flag.

    eg.

    seen URL = http://domain.com/page/about/
    real URL = http://domain.com/page.php?op=about

    now page.php needs to call the getimagesize() function
    the images being located in domain.com/images/

    if you put in getimagesize("images/img.jpg") it works fine, but if you're sitting on the URL that's been re-written then it can't find the image since it thinks it's in domain.com/page/about/images/

    if however you put in getimagesize("/images/img.jpg") then the image location would be correct, but getimagesize() now triggers a open_dir restriction.


    any suggestions?

  2. #2
    ✯✯✯ silver trophybronze trophy php_daemon's Avatar
    Join Date
    Mar 2006
    Posts
    5,284
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Well as you said it, the rewritten url is only seen by the end user. It does not affect the server side directory structure. You should be able to use getimagesize("images/img.jpg") as if you use it with no rewritten urls.

    /images/img.jpg is a unix absolute path, same if you write c:\images\img.jpg in windows.
    Saul

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    keep in mind that relative filepaths must be converted to absolute filepaths by php. php will join the relative filepath with its current working dir to craft the absolute filepath.

    you can see what php's current working dir is by
    echo getcwd();


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
  •