Assistance with .htaccess folder rewrite

I want to do an .htaccess rewrite for an image uploader I have on my site, but for all the tutorials I've tried, I can’t get it working.

Currently, the code I have uploads images to the folder: http://www.example.com/server/php/files/jkgh4f54.jpg

I’d like to rewrite it so when you go to this URL: http://www.example.com/jkgh4f54.jpg it is showing the image from the above location.

Any thoughts? As I mentioned, there are a lot of tutorials everywhere about stuff similar to this, but I haven't been able to adapt them to work thus far for me.

Current .htaccess:

RewriteEngine On
RewriteCond %(REQUEST_FILENAME} !-f [OR]
RewriteCond %(REQUEST_FILENAME} !-d
RewriteRule ^[a-zA-Z0-9]+\.(jpe?g|png|gif|bmp)$ /server/php/files/$0 [L]
RewriteRule ^([a-zA-Z0-9]+)$ index.php?code=$1 //For URL Shortener
ErrorDocument 404 http://localhost/site.com/404.php

Answers


Using this code, when the user visits http://example.com/h3h2js.jpg, they will see the image from http://example.com/server/php/files/h3h2js.jpg, but the URL in the browser will stay the same:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^[a-zA-Z0-9]+\.(jpe?g|png|gif|bmp)$ /server/php/files/$0 [L]

I have tested this code thoroughly on a clean installation of XAMPP on Windows. Image names must only contain alphanumeric characters of either case (a-z, A-Z, 0-9), and must end with a jpg, jpeg, png, gif or bmp file extension. If the requested image file already exists in the site root, the rewrite will not take place


Need Your Help

JavaScript access elements from custom object

javascript oop

This must be a very stupid question, but I just can't get it to work.

Every flash uploader giving bad progress values

flash yui uploadify swfupload

The file upload script I wrote early last year for an internal website has been misbehaving oddly on a number of machines. On some machines it consistently works fine, on others it consistently

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.