mod_rewrite help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Cloak
    Registered User
    • Jul 2003
    • 56

    #1

    mod_rewrite help

    Hey folks, wondering if I can get some help with this problem.

    I want to have certain pics show their thumbnailed equivalent when called from a website other than my own, how would I go about doing this? I don't want to blanked redirect to just one pic, I'd like it to go to the same pic but one level down in the thumbs dir.

    I was thinking something like this would work, but doesn't:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^http://sitetoshowthumbs.com/$ [NC]
    RewriteCond %{REQUEST_URI} ^/([0-9]+)/
    RewriteRule ^/(.*)$ http://mysite.com/files/%1/thumbs/$1 [L]
    The pictures would be in:

    http://mysite.com/files/1/pic.jpg
    http://mysite.com/files/1/thumbs/pic.jpg

    I'd like to only do this for jpg, jpeg, png, and gif files.

    Any pointers would be great, I just can't seem to get my head around how to do it. Thanks in advance.
    Good cheap webhosting
    Post your homegrown pics here
  • Cloak
    Registered User
    • Jul 2003
    • 56

    #2
    Got my answer, I figure I might as well share:

    Code:
    RewriteEngine on
    RewriteCond %{HTTP_REFERER} ^[url]http://othersite.com/[/url] [NC]
    RewriteCond %{REQUEST_URI} !^/files/([^/]+)/thumbs
    RewriteCond %{REQUEST_URI} ^/files/([0-9]+)/([^.]+\.(jpg|gif|png))$ [NC]
    RewriteRule ^.*$ /files/%1/thumbs/%2 [R]
    Good cheap webhosting
    Post your homegrown pics here

    Comment

    Working...