Redirect example.com/filename.jpg to example.com/uploads/filename.jpg with .htaccess
I want to redirect example.com/filename.jpg
to example.com/uploads/filename.jpg
with .htaccess
.
How can I do this?
.htaccess in your web root directory:
RewriteRule ^filename.jpg$ uploads/filename.jpg [L]
Or, you can write a more general rule that will match all requests for /*.jpg with /uploads/*.jpg
RewriteRule ^(\w+)+.jpg$ uploads/$1.jpg [L]
As with all things, you're better off actually learning how to use mod_rewrite instead of just asking for the answer to very specific examples: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html
精彩评论