0
我需要帮助URL重写提供默认图像时找不到请求的文件。构建URL重写规则为htaccess为404未找到
我想要写3种不同的图像URL格式规则:
(1)http://example.com/imgs/user/123-profile.jpg
(2)http://example.com/imgs/user/123-profile-987.jpg
(3)http://example.com/imgs/user/123-678.jpg
如果(1)和(2)未找到,则应提供“http://example.com/imgs/user/default-user.jpg”;如果(3)未找到,则应提供“http://example.com/imgs/user/default-post.jpg”。
我试着在 “.../IMGS /用户/ htaccess的” 文件如下代码:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)imgs/user/([0-9]*)[-profile]([0-9]*).jpg$ /imgs/user/default-user.jpg [L]
RewriteRule ^(.*)imgs/user/([0-9]*)[-]([0-9]*).jpg$ /imgs/user/default-post.jpg [L]
也请告诉我 - 我应该把代码中的.htaccess以 “/”(文档根目录)或当前路径更受欢迎。
感谢您抽出宝贵的时间,但遗憾的是它不工作。 – 2014-09-24 13:21:03