重定向原始.gif文件通过.htacces到处理器页处理器、重定向、原始、文件

由网友(24.小嘴欠吻)分享简介:我有一个病毒图片的网站,人们可以看到搞笑的GIF。很多人在Reddit上共享原始.gif文件但是,而不是.gif注意嵌入页面。这是好的 - 但我想重定向浏览RAW图像.gifs到一个处理页面调用shareraw.php(位于根目录)所有的人。此处理程序页面的外观完全一样的 - 只是一个共享链接和按钮,检查出现场的其余部...

我有一个病毒图片的网站,人们可以看到搞笑的GIF。很多人在Reddit上共享原始.gif文件但是,而不是.gif注意嵌入页面。这是好的 - 但我想重定向浏览RAW图像.gifs到一个处理页面调用shareraw.php(位于根目录)所有的人。此处理程序页面的外观完全一样的 - 只是一个共享链接和按钮,检查出现场的其余部分

I have a viral image site where people can view funny gifs. A lot of people on reddit are sharing the raw .gif files however, rather than the page with .gif embedded. This is fine - but I'd like to redirect all people viewing raw image .gifs to a handler page called shareraw.php (located in root directory). This handler page will look exactly the same - just with a share link and button to check out the rest of the site.

我创建的页面。所有我现在需要的是正确的.htaccess命令做什么,我描述。请帮忙!感谢:)

I've created the page. All I need now is the correct .htaccess commands to do what I've described. Please help! Thanks :)

推荐答案

您可以通过检查的 HTTP_REFERER 的的的 .gif注意:的请求做到这一点。如果请求不是从您的网站来了,你将用户重定向到您的 shareraw.php 的文件。

You can do this by checking the HTTP_REFERER for .gif requests. If the request isn't coming from your site, you redirect the user to your shareraw.php file.

添加到您的的.htaccess 在Web根 / 目录。

Add this to your .htaccess in your web root / directory.

Options +FollowSymLinks -MultiViews
RewriteEngine on

RewriteCond %{HTTP_REFERER} !^http://(www.)?mysite.com/ [NC]
RewriteCond %{REQUEST_URI} /uploads/.*.gif$ [NC]
RewriteRule ^(.*)$ /shareraw.php?img=$1 [R,L]

您将只需要调整规则以适应在您的病毒图档存储以及如何GIF名或路径传递到您的 shareraw.php 的。

You'll just need to tweak the rules to accomodate where your viral gifs are stored and how the gif name or path is passed to your shareraw.php.

阅读全文

相关推荐

最新文章