I want to rewrite a URL.
Let's say you visit http:开发者_高级运维//files.domain.com/uploads/file_name.jpg
How can I use htaccess to write it so I can access it via http://files.domain.com/file_name.jpg?
Thanks.
Try putting following lines in your root .htaccess file
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} ^/[^/]*\.jpg [NC]
RewriteRule ^([^/]*\.jpg)$ /uploads/$1 [L,NC]
精彩评论