catalyst2 community forums  

Go Back   catalyst2 community forums > Support > Scripting Support

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
Old 05-01-2008, 11:45 AM   #1 (permalink)
Registered User
 
Join Date: Feb 2004
Location: Essex, UK
Posts: 88
Creating a rewriteCond in .htaccess

I've a php script which creates thumbnail images, which is part of the CMS of my website. However, this also means I can't use it directly within vB or phpBB forums, as [img]script.php?image=xyz.jpg[/img] just doesn't work.

What I'd like to do is create a 'fake' file, eg, http://www.creapsoft.co.uk/thumbs/chrisjlocke/03012008/file.jpg
which (via .htaccess) will be re-written as http://www.creapsoft.co.uk/protectedimage.php?image=chrisjlocke/file.jpg_03012008&cachedimage=true&width=200

Could it be done? Could someone give me some pointers please?
Chris Locke is offline   Reply With Quote
Old 08-01-2008, 03:48 PM   #2 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Chris,

It can be done, I will see what I can dig out for you, regex isnt my forte
paulredpath is offline   Reply With Quote
Old 08-01-2008, 04:12 PM   #3 (permalink)
Registered User
 
Join Date: Feb 2004
Location: Essex, UK
Posts: 88
Thanks!
I don't know much about regular expressions either, but I didn't know if you could simply split the URL up into 'lumps' (using the / as a delimiter) and then I could use $1, $2, etc in the rewriteCond.
I might be talking out of my bottom though...
Chris Locke is offline   Reply With Quote
Old 10-01-2008, 11:32 AM   #4 (permalink)
Registered User
 
Join Date: Feb 2004
Location: Essex, UK
Posts: 88
So far I've got this, but the server doesn't appear to be catching it.

RewriteRule /thumbs/(.*)/(.*)\.jpg_(.*)\.jpg$ /protectedimage.php?image=$1/$2.jpg_$3&cachedimage=true&width=200 [R=301,L]

I've had to tweak the URL slightly from my opening post. The URL I'm passing it is http://www.creapsoft.co.uk/thumbs/ch...g_07012008.jpg and it should be re-mapping it to http://www.creapsoft.co.uk/protected...true&width=200

I've downloaded RegexBuddy, which confirms it *should* work, but all I'm getting is a 404. Its not clear from the weblogs why though - just that the URL passed couldn't be found (rather than the rejigged URL being wrong).

Last edited by Chris Locke; 10-01-2008 at 11:35 AM.
Chris Locke is offline   Reply With Quote
Old 10-01-2008, 12:03 PM   #5 (permalink)
Registered User
 
Join Date: Feb 2004
Location: Essex, UK
Posts: 88
Grr. Got it. URL doesn't start with a slash. Replace with a ^ and all is well! Argh!
Chris Locke is offline   Reply With Quote
Old 10-01-2008, 01:43 PM   #6 (permalink)
Bring me your problems :p
 
paulredpath's Avatar
 
Join Date: Jan 2003
Location: /dev/ahhhhhhhhh
Posts: 3,537
Chris,

Sorry for not getting back to you, glad you got it sorted
paulredpath is offline   Reply With Quote
Old 10-01-2008, 02:26 PM   #7 (permalink)
Registered User
 
Join Date: Feb 2004
Location: Essex, UK
Posts: 88
Thanks for the offer anyway! Appreciated!
Chris Locke is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:53 AM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.