我想对我网站上的图像上传器进行 .htaccess 重写,但是对于我尝试过的所有教程,我无法让它工作。
目前,我将图像上传到文件夹的代码:
http://www.example.com/server/php/files/jkgh4f54.jpg
我想重写它,所以当您访问此 URL 时:http://www.example.com/jkgh4f54.jpg
它显示来自上述位置的图像。
有什么想法吗?正如我所提到的,到处都有很多关于类似内容的教程,但到目前为止,我还无法让它们适应我的工作。
当前的.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