简体   繁体   English

重定向请求(htaccess)

[英]Redirect requests (htaccess)

I have this rule: 我有这个规则:

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?site\.com/ [NC]
RewriteRule .*\.(gif)$ gif.php [L]

As i know, its redirecting ALL requests to *.gif files. 据我所知,它会将所有请求重定向到* .gif文件。 How i must to edit this rule to redirect requests only /uploads/ folder? 我必须如何编辑此规则以仅重定向请求/ uploads /文件夹?

Sorry for my English (: 对不起我的英语不好 (:

Rewrite it as follows: 如下重写:

RewriteCond %{HTTP_REFERER} !^http://(.+\.)?site\.com/ [NC]
RewriteRule uploads/.*\.gif$ gif.php [L]

Now it redirects only request made to a gif file inside uploads folder. 现在,它仅将发出的请求重定向到uploads文件夹中的gif文件。

Be careful, it's redirecting everything to a gif.php inside your document root. 注意,它将所有内容重定向到文档根目录内的gif.php The uploads folder will not be part of the new request. uploads文件夹将不属于新请求。

If you want to redirect requests to GIF files inside the /uploads/ path, you'll do: 如果要将请求重定向到/ uploads /路径内的GIF文件,请执行以下操作:

RewiteCond %{HTTP_REFERER} !^http://(.+\.)?site\.com/ [NC]
RewriteRule ^/uploads/.*\.gif$ gif.php [L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM