Quick htaccess question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tipsy
    Confirmed User
    • Jul 2001
    • 6989

    #1

    Quick htaccess question

    Something I've never had to do before...

    I need to pop up a standard 'no image available' image on a site whenever an image is broken. It has a huge database and manually digging out broken images to replace them would take hours.

    Any ideas?
    Ignorance is never bliss.
  • AlienQ - BANNED FOR LIFE
    best designer on GFY
    • Mar 2003
    • 30307

    #2
    Use HTACCESS

    Comment

    • Tipsy
      Confirmed User
      • Jul 2001
      • 6989

      #3
      Ignorance is never bliss.

      Comment

      • Tipsy
        Confirmed User
        • Jul 2001
        • 6989

        #4
        Quick bump in case anyone knows. Not sure it's even possible though.
        Ignorance is never bliss.

        Comment

        • fusionx
          Confirmed User
          • Nov 2003
          • 4618

          #5
          Originally posted by Tipsy
          Quick bump in case anyone knows. Not sure it's even possible though.
          I think you would be better off adding code to your script to check for the existence of the image, and replace it as needed. I don't think you can detect the missing image and have it be replaced using mod_rewrite in htaccess without opening the door to a whole bunch of other problems.

          Comment

          • swedguy
            Confirmed User
            • Jan 2002
            • 7981

            #6
            There's a way to do it with mod_rewrite. Give me a minute and I'll dig it up for you.

            Comment

            • swedguy
              Confirmed User
              • Jan 2002
              • 7981

              #7
              http://httpd.apache.org/docs/mod/mod...ml#RewriteCond

              -f' (is regular file)
              Treats the TestString as a pathname and tests if it exists and is a regular file.

              You will probably find an example of it on this page:

              http://httpd.apache.org/docs/misc/rewriteguide.html

              Comment

              • Tipsy
                Confirmed User
                • Jul 2001
                • 6989

                #8
                Thanks I'll give it a go. If not then yep - looks like a script thing which'll keep me busy while I try to get my head back into php mode - it's been a while
                Ignorance is never bliss.

                Comment

                • Lycanthrope
                  Confirmed User
                  • Jan 2004
                  • 4517

                  #9
                  Fusionx is probably right, but this should work:

                  RewriteEngine on
                  RewriteCond %{REQUEST_FILENAME} !-f
                  RewriteRule \.jpg$ /path/to/missing.jpg [L]

                  but be prepared for much more cpu usage

                  Comment

                  • Tipsy
                    Confirmed User
                    • Jul 2001
                    • 6989

                    #10
                    Originally posted by Lycanthrope
                    Fusionx is probably right, but this should work:

                    RewriteEngine on
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteRule \.jpg$ /path/to/missing.jpg [L]

                    but be prepared for much more cpu usage
                    Problem with that is it wants a fairly specific filename and they can vary hugely but thanks for the suggestion. I'll try the first idea in a bit and see how it goes
                    Ignorance is never bliss.

                    Comment

                    • Tipsy
                      Confirmed User
                      • Jul 2001
                      • 6989

                      #11
                      Originally posted by Lycanthrope
                      Fusionx is probably right, but this should work:

                      RewriteEngine on
                      RewriteCond %{REQUEST_FILENAME} !-f
                      RewriteRule \.jpg$ /path/to/missing.jpg [L]

                      but be prepared for much more cpu usage

                      Scrap the reply above. I replied without thinking or looking at the apache docs. It works more than fine and the CPU usage should be OK as it's a non-porn site so traffic is manageable Thanks.
                      Ignorance is never bliss.

                      Comment

                      • Sosa
                        In Tushy Land
                        • Oct 2002
                        • 40149

                        #12
                        your fucking sig sucks ass.

                        Comment

                        Working...