LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 12-09-2013, 04:34 PM   #1
fruitwerks
Member
 
Registered: Apr 2009
Posts: 80

Rep: Reputation: 15
mod-rewrite / phpthumb / direct link protection


I'm sure this can be done, but I have no idea where to start, also I am not very good with rewrite.

Basically, I have images in /gallery/misc/folders/image.jpg. I watermark and resize them as I need with phpThumb. Now it is easy to inspect and figure out where the original resides on the server.

I would like have apache internally hijack any direct linking to the original and force the request to be rewritten so that a watermark will be applied.

So if I go to http://mysite.com/gallery/427/image.jpg I should be redirected to something like;

http://mysite.com/pt/process-img.php.../427/image.jpg[options here]

Thanks!
 
Old 12-10-2013, 02:37 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Hi,

You may try the following rewrite rule:
Code:
RewriteEngine On

RewriteCond %{REQUEST_URI} ^/gallery
RewriteRule /gallery/(.*)/(.*) /pt/process-img.php&image=gallery/$1/$2
The above is to be placed in the apache config file. If you want to put it in a .htaccess file, remove the leading slash in the RewriteRule:
Code:
RewriteRule gallery/(.*)/(.*) /pt/process-img.php&image=gallery/$1/$2
Regards
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mod rewrite suj Linux - Server 5 03-18-2012 04:35 AM
Need some mod rewrite help carters2 Linux - Server 10 04-04-2011 07:47 PM
conf :Mod rewrite,Mod Jkand virtualhosts ayyappansan Linux - Server 1 10-25-2009 03:10 AM
Apache2 mod vhost_alias - problems with .htaccess mod rewrite d_t_baker Linux - Server 1 08-16-2007 07:32 PM
Mod Rewrite Help carminejg3 Linux - Software 0 12-20-2004 05:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 03:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration