通过.htacces重定向原始.gif文件来处理网页 - 我的code不起作用 [英] Redirect raw .gif files to handler page via .htacces - my code doesn't work

查看:127
本文介绍了通过.htacces重定向原始.gif文件来处理网页 - 我的code不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

原始图像位置范例: HTTP: //gifsec.com/wp-content/uploads/GIF/2015/03/Scared-Reaction-Gif.gif

分享网页位置: http://gifsec.com/shareraw.php

下面是我的code目前这是行不通的。当我去到原始的gif,什么都不会发生:

 #BEGIN字preSS
< IfModule mod_rewrite.c>
RewriteEngine叙述上
的RewriteBase /
重写规则^指数\ .PHP $  -  [L]
的RewriteCond%{} REQUEST_FILENAME!-f
的RewriteCond%{} REQUEST_FILENAME!-d
重写规则。的index.php [L]
< / IfModule>

#结束字preSS

选项​​+的FollowSymLinks -MultiViews
RewriteEngine叙述上

的RewriteCond%{HTTP_REFERER} ^ HTTP://(WWW \)gifsec.com \ .COM / [NC]
的RewriteCond%{REQUEST_URI} /uploads/GIF/.*\.gif$ [NC]
重写规则^(。*)$ /shareraw.php?img=$1 [R,L]


## EXPIRES CACHING ##
< IfModule mod_expires.c>
ExpiresActive在
ExpiresByType图像/ JPG的访问权限1年
ExpiresByType为image / jpeg的访问权限1年
ExpiresByType图像/ GIF的访问权限1年
ExpiresByType图像/ PNG的访问权限1年
ExpiresByType文本/ CSS的访问权限1月
ExpiresByType text / html的访问权限1月
ExpiresByType应用程序/ PDF的访问权限1月
ExpiresByType文/ X-的javascript访问权限1月
ExpiresByType应用程序/ x-冲击波闪光的访问权限1月
ExpiresByType图像/ X-图标的访问权限1年
ExpiresDefault访问权限1月
< / IfModule>
## EXPIRES CACHING ##
 

解决方案

好吧,我们重定向GIF到专用页面。该网页将如何呈现GIF?同样,使用gif文件?循环开始了。

您可以在使用PHP的结合htaccess,但你必须要改变的图像显示在所有位置实现。 (但不是万无一失的)

根据场地的大小,努力进行估计。

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.

Example of raw image location: http://gifsec.com/wp-content/uploads/GIF/2015/03/Scared-Reaction-Gif.gif

Share page location: http://gifsec.com/shareraw.php

Here is my code currently which is not working. When I go to a raw gif, nothing happens:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Options +FollowSymLinks -MultiViews
RewriteEngine on

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


## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

解决方案

Ok, we redirect the gif to the dedicated page. How will that page render the gif? Again, using gif file? loop begins.

You can achieve it using combination of PHP with htaccess but you will have to change image display at all location. (though not foolproof)

Depending on the site size, efforts can be estimated.

这篇关于通过.htacces重定向原始.gif文件来处理网页 - 我的code不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆