19
08年四月
防止GetRight和Curl来抓取网內的数据的代码
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^curl [OR]
RewriteCond %{HTTP_USER_AGENT} ^GetRight
RewriteRule ^.* - [F]
阅读全部»
贝贝爸 发表在 技术文章 |
22
07年三月
实现的原理很简单,就是apache的url_rewrite功能+php程序
url_rewrite代码
- [test@test htdocs]$ cat .htaccess
- # BEGIN WordPress
- <IfModule mod_rewrite.c>
- RewriteEngine On
- RewriteRule ^images/logo\.jpg$ /test/randomimg.php [L]
- </IfModule>
php代码
- <?php
- /*
- * Created on 2007-3-20
- *
- * To change the template for this generated file go to
- * Window - Preferences - PHPeclipse - PHP - Code Templates
- */
- header("Content-Type: image/jpeg");
- $dir = './images/';
-
- $imgarr=array();
- if ($handle = opendir($dir)) {
- while (false !== ($file = readdir($handle))) {
- if (preg_match ("/(.*?)\.jpg$/i", $file) ) {
- array_push($imgarr,$dir.$file);
- }
- }
- closedir($handle);
- }
- //srand ((float) microtime() * 10000000);
- readfile($imgarr[array_rand ($imgarr)]);
- ?>
只要把把要显示的图片放到
$dir目录里就可以了:)
效果点击这里,或者刷新本页面,看右上角的图片。
贝贝爸 发表在 原创技术文章 |
17
07年三月
实现的目的就是:
访问http://www.domin.com/user/*.*时
全部rewrite到对应的http://www.domin.com/*.*
当然包含子目录
譬如对http://www.domin.com/user/news/A01.htm时
会对应到http://www.domin.com/news/A01.htm
- Options +FollowSymLinks
- RewriteEngine on
- RewriteRule user/(.*)$ $1
放在“/”测试通过
贝贝爸 发表在 原创技术文章 |