0

当用户来自谷歌图片搜索时,我需要将“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]
4

1 回答 1

0

尝试:

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]
于 2013-10-03T04:33:54.887 回答