Results 1 to 6 of 6
  1. #1

    YA .htaccess thread

    I searched around, but couldn't find something like this.

    I want to redirect requests like this
    (note: {NNNN}.jpg does not exist and never will.)



  2. #2
    Join Date
    Dec 2002
    NY, NY
    hm... dont know if its possible..
    I mean you want any image to be redirected? or just those?
    Those would be easy..
    But any, im not sure how.

  3. #3
    This should do it (can't test now though).

    RewriteRule ^([0-9]+)\.jpg$ script.php?id=$1

  4. #4

    I tried that one and no luck... I think the problem is that my hosting company has done some peculiar things at a higher level, which are causing a conflict in the rules I am trying to create.

    To further complicate matters, I have recently re-branded a site, but still have to support some legacy URLs for existing customers. The old URLs are on a completely different domain. In fact, there are a few URLs in play.

    These three things all resolve to the same site.

    The fundamental problem here is that this whole thing grew out of a programming project I did for fun, and was not planned in the way I would have preferred. So many reasons why this is a non-ideal solution....

    Anyway... directory structure - this is where it gets insane.

    Base path for all my stuff:

    Next level:

    htdocs/ (this is where .htaccess is and is my "primary" documentroot"
    pgallery/ (this supports the url, which is enabled by default by my host's server config, as a subdomain.)
    stuff/ (supports url, also a subdomain controlled by my host's server config.)

    within htdocs:
    symlink named easyimagehost, pointing to the "pgallery" folder one level up.

    Now, here's my full set of current rewriting rules.

    RewriteEngine On
    Options +FollowSymlinks
    RewriteBase /
    RewriteCond %{HTTP_HOST}
    RewriteCond %{REQUEST_URI} !easyimagehost/
    RewriteRule ^(.*)$ easyimagehost/$1 [L] 
    RewriteRule ^([0-9]+)\.jpg$ img_load.php?imageid=$1
    All but the last one work fine.

    With the last one in place, I get the following in my error_log when I try the following url:

    File does not exist: /www/e/a/
    Where the heck it's getting that stuff from in the root path, I have no idea.

    The goal is for this:

    to redirect to this:
    (Note: this url works fine, and does exactly what it's supposed to do.)

    My head hurts.

  5. #5
    Left to my own devices....

    RewriteCond %{HTTP_HOST}
    RewriteRule ^([0-9]+)$ /img_load.php?imageid=$1 [L]
    RewriteRule ^([0-9]+)\/([0-9]+)$ /img_load.php?imageid=$1&rz=$2 [L]
    RewriteRule ^([0-9]+)\.jpg$ /img_load.php?imageid=$1 [L]
    RewriteCond %{REQUEST_URI} !easyimagehost/
    RewriteRule ^(.*)$ easyimagehost/$1
    That works.

    Now, the following url...

    Will actually work.

    As will this:

    And this too...

  6. #6
    Join Date
    Aug 2002
    Hong Kong
    how about redirecting every single request to a script?

    in that way the image url could be a combination of alphanumeric values like:
    ht tp://

    the length of urls can be shortened dramatically:
    36 to the power of (length of the url)

    the script can also display html content for urls like:
    ht tp://domain/html/page1 or simply
    ht tp://domain/-/page2
    ht tp://domain/

    just a piece of suggestion, not to be taken seriously

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts