.htaccess url rewrite

后端 未结 1 958
旧巷少年郎
旧巷少年郎 2021-01-27 14:11

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://file

相关标签:
1条回答
  • 2021-01-27 15:04

    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] 
    
    0 讨论(0)
提交回复
热议问题