Forum Moderators: phranque
http://www.example.com/folder/folder/image.jpgbecomes...
http://www.example.com/script.php?s=folder/folder/image.jpg
Here's my htaccess code.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteCond %{REQUEST_FILENAME} \.(gif¦jpe?g?¦png)$ [NC]
RewriteRule ^(.*)$ /gallery.php?s=$1 [R=301,L]
Any clue as to why that is?
[edited by: jdMorgan at 4:23 am (utc) on Jan. 29, 2008]
[edit reason] example.com [/edit]
Also, this shouldn't even be a redirect, since it exposes your script, and removes any 'security' advantage that the script might provide.
The rule (or rules) need to be more selective about URL-paths, and HTTP request phases in order to work.
Can't suggest a solution right now... Maybe someone else will see something that's not obvious to me right now.
Jim
DirectoryIndex index index.php index.html<Files index>
ForceType application/x-httpd-php
</Files>
..to force the file to be parsed, thus making the url look like,
http://www.domain.com/index/folder/folder/image.jpg
Tried that out and it did work, but again if somebody went direct to the image and I tried to redirect them, none of the images showed up on the page.
I'm sure I've seen this done. :(
As it stands now, all images on your site will be redirected to your gallery script.
Don't complicate things by trying to use extensionless URLs before you get the basic image rewriting sorted; You will end up with a 'layered' problem, which will be *much* more difficult to fix.
And again, as stated, you'll likely be happier changing these redirects to internal rewrites -- after you get the basic URL issues worked out.
Consider putting your images into two subdirectories; One for image-script gallery images, and the other for images that are part of your pages -- logos, buttons, icons, backgrounds, etc. Then your mod_rewrite rules will be able to tell which image requests need to be routed through your script.
Jim