开发者

Redirect example.com/filename.jpg to example.com/uploads/filename.jpg with .htaccess

开发者 https://www.devze.com 2022-12-23 23:12 出处:网络
开发者_运维技巧I want to 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

0

精彩评论

暂无评论...
验证码 换一张
取 消