.htaccess 中的条件

Condition in .htaccess

有没有办法在 .htaccess (mod_rewrite) 中编写条件以应用重定向规则如果引荐来源网址包含“.google”。同时在接受 header.

中找不到 "image"

到目前为止,我的规则适用于所有请求(除了我的域)图像重定向到我的包含该图像的网页。因此,现在它不再在空白页面中显示图像,而是重定向到 post.

RewriteEngine on

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain\.com [NC]
RewriteRule ^manufacturers/([^/]+)/[^/]+/([^/]+)/[^/.]+\.jpe?g$ // [L,NC,R=302]

RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domain\.com [NC]
RewriteRule ^manufacturers/([^/]+/[^/]+)/[^/.]+\.jpe?g$ / [L,NC,R=302]

现在我想允许所有请求,除非引荐来源网址包含“.google”。同时在接受 header.

中找不到 "image"

如果你能回答,至少请分享一些资源,以便我解决。

提前致谢

你应该可以使用这个:

RewriteCond %{HTTP_REFERER} \.google\.
RewriteCond %{HTTP_ACCEPT} !image
RewriteRule ^manufacturers/([^/]+/[^/]+)/[^/.]+\.jpe?g$ / [L,NC,R=302]