if a site with a set of programs binding multiple domain name www.a.com, www.b.com, in order to distinguish their robots.txt, Baidu webmaster verification files, such as www.a.com/robos.txt content from/virtual/ The contents of the Www.a.com/robots.txt Www.b.com/robots.txt are derived from the/virtual/www.b.com/robots.txt method:%{request_filename}!-f^ ([a-za-z0-9_]{2,32}\. ( xml|html|txt)) seo.php?file=$1 [L]
File/seo.php
<?php/** * @paramstring $msg */function_404 ($msg= "'){ Header(' http/1.1 404 Not Found '); Header(' status:404 not Found '); // ensure thatFastCGINormal Mode if(Empty($msg)) $msg= ' 404 Not Found. '; Exit($msg);}functionGetext ($file){ returnSTRRCHR($file, '. ');}$file= Trim($_get[' file ']);if(!Preg_match('/^[a-za-z0-9_]{3,32}\. (html|txt|xml) $/i ', $file) ) _404 ();$dir= ' virtual/'. Strtolower($_server[' Http_host ']);if(!Is_dir($dir) ) _404 ();$filePath= $dir. '/'. $file;if(file_exists($filePath) &&Is_file($filePath)) { Switch(Getext ($file)) { Case'. txt ': $type= ' Text/plain; Charset=utf-8 '; Break; Case'. xml ': $type= ' Application/xml '; Break; Case'. html ': default: $type= ' text/html; Charset=utf-8 '; Break; } off(!Empty($type)) { Header(' Content-type: '. $type); } Echofile_get_contents($filePath);} Else{_404 ();}
PHP rewrite read files, applicable to multi-domain conditions!