.htaccess 需要使用htaccess删除图像扩展

.htaccess 需要使用htaccess删除图像扩展,.htaccess,mod-rewrite,redirect,.htaccess,Mod Rewrite,Redirect,我需要改变或重定向“example.com/photos/logo.jpg”到“example.com/photos/logo”当用户来自谷歌图像搜索 因此,我使用了: RewriteCond %{REQUEST_URI} photos/.*\.(gif|jpg|jpeg|png)$ [NC] RewriteCond %{HTTP_REFERER} ^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/url\?.*$ [NC,OR] RewriteCon

我需要改变或重定向“example.com/photos/logo.jpg”到“example.com/photos/logo”当用户来自谷歌图像搜索

因此,我使用了:

 RewriteCond %{REQUEST_URI} photos/.*\.(gif|jpg|jpeg|png)$ [NC]
 RewriteCond %{HTTP_REFERER} ^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/url\?.*$ [NC,OR]
 RewriteCond %{HTTP_REFERER} ^http://www.bing.com/images/search?q=\?.*$ [NC,OR]
 RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC]
 RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]
 RewriteRule ^gallery/(.*) /$1 [L,R=301]
尝试:

RewriteCond %{HTTP_REFERER} ^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/url\?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} ^http://www.bing.com/images/search?q=\?.*$ [NC,OR]
RewriteCond %{HTTP_REFERER} !^http://example.com/.*$ [NC]
RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]
RewriteRule ^photos/(.*)\.(jpe?g|png|gif)$ /photos/$1 [L,NC,R=301]