SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Mod rewrite images questions

    Im using mod rewrite using:

    ^mod/(.*)/ index.php?mod=$1

    The mod works as it should:
    www.somesite.com/mod/3

    The problem is the images are broken as well as the css. If you look at the image location in the page it shows:

    www.somesite.com/mod/3/images/someimage.gif

    So my question is do I have to use a relative bath to images? Or am I missing something in the mod rewrite?

    Thanks
    Silly

  2. #2
    3MTA3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    1,016
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    absolute paths should fix it

  3. #3
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that normal to give absolute path? What if I move the site to a different domain?

    Silly

  4. #4
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bump..

    Seriously, is this normal linking when using mod_rewrite? Use absolute path? Or am I doing something wrong in the rewrite? Or am I missing something?


    Silly

  5. #5
    SitePoint Guru
    Join Date
    May 2003
    Location
    virginia
    Posts
    988
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, this is something that has always bothered me about screwing with the path after the requested file. Any slash after the request file makes the "relative" location that much deeper. I think one solution *could* be to set the doc/root meta tag in the final document head tag. Of course this is only going to work for a page if it has a single template/page that's been included at X level. Different templates/pages that are combined into one document coming from different directory levels, hmmm. That's tough. The more I write the more I'm thinking absolute paths are the only way to go? I've seen a lot of sites out there that completely break if you put a slash and some stuff after the requested file.

    -matt

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    > Is that normal to give absolute path? What if I move the site to a different domain?

    Absolute path != absolute url.

    "img/a/b/c/pic.gif" is a relative path
    "/img/a/b/c/pic.gif" is an absolute path
    "http://domain.com/img/a/b/c/pic.gif" is an absolute url

    It's common to use absolute paths (not urls) with mod_rewrite. An alternate solution would be to add separate rewrite rule for images, something like

    RewriteRule .+(/img/.+)$ $1


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
  •