mod_rewrite changes my <img src=

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • superfly
    Member
    • Mar 2004
    • 80

    #1

    mod_rewrite changes my <img src=

    Hello, I've got a bit of a problem with mod_rewrite.

    I am rewriting urls that look like this:
    presents-cerruti.php?code=N4359&descripton=some_present

    into URL's that look like this:
    presents-cerruti/N4359/some_present

    with this rules:
    RewriteEngine On
    RewriteRule ^presents-cerruti/(.*)/(.*) /presents-cerruti.php?code=$1&description=$2

    The problem is, when I click the link, the images dont't work anymore, because the URL is rewritten and the images can't be found.

    How can I avoid this?
  • Jonathan
    Senior Member
    • Mar 2004
    • 1229

    #2
    How are the URLs formated in the images? Are they using
    PHP, maybe specific images per something in the URL, etc?

    Also whats the path to the relative path
    to the images from the root?
    "How can someone be so distracted yet so focused?"
    - C

    Comment

    • sdjl
      Senior Member
      • Mar 2004
      • 502

      #3
      Pretty much as Jonathan says.
      You probably have your image tag setup to be <img src="image.gif">
      Therefore when you use your custom URLs, it will be looking for

      /presents-cerruti/N4359/some_present/image.gif

      You need to tell your image tags to look in the base URL rather than the sub folders.

      David
      -----
      Do you fear the obsolescence of the metanarrative apparatus of legitimation?

      Comment

      • djn
        Senior Member
        • Mar 2004
        • 140

        #4
        You may put in the head section of your pages the line
        <base href="http://www.yoursite.com"> and refer to the images (and other files, like css and javascripts) relatively to the server root (eg. <img src=images/myimage.gif>).

        djn

        Comment

        • -Oz-
          Senior Member
          • Mar 2004
          • 545

          #5
          Wow, didn't know that base href thing, thats cool.
          Dan Blomberg

          Comment

          • superfly
            Member
            • Mar 2004
            • 80

            #6
            Yup, verry nice. Solved my problem, thanks.

            Comment

            Working...