-
Migrating a Web site to Windows IIS from the Linux server Nginx
Data what is the problem, after the configuration of rewrite, visit the site, found that the style changes, the site is empty a piece
I use the Chrome browser to look at the elements, found that the head of the contents of the body, and the body of the first out of a number of a quoted blank!
But if you right-click on the source code, the code is correct, no problem!
Normal state
Error status
Begging Daniel to save
Cause of the problem:
The site uses UTF-8 no BOM encoding, but when using include or require contains a file, contains a UTF-8 with a BOM file, the above phenomenon.
Workaround:
Go to BOM for all files on the site
Clearbom.php (put to the root directory to execute, back up the website before execution, in case of contingency)
02 |
$basedir = str_replace ( ‘/clearBOM.php‘ , ‘‘ , str_replace ( ‘\\‘ , ‘/‘ ,dirname( __FILE__ ))); |
05 |
function checkdir( $basedir ){ |
06 |
if ( $dh = opendir( $basedir )) { |
07 |
while (( $file = readdir( $dh )) !== false) { |
" |
; if $file !=  && $file != |
" |
; if (! is_dir $basedir '/' $file |
ten |
; $filename = $ Basedir '/' $file |
one |
; echo $basedir '/' $file .checkbom ( $filename ' <br> ' |
13 |
$dirname = $basedir . ‘/‘ . $file ; |
22 |
function checkBOM ( $filename ) { |
24 |
$contents = file_get_contents ( $filename ); |
25 |
$charset [1] = substr ( $contents , 0, 1); |
26 |
$charset [2] = substr ( $contents , 1, 1); |
27 |
$charset [3] = substr ( $contents , 2, 1); |
28 |
if (ord( $charset [1]) == 239 && ord( $charset [2]) == 187 && ord( $charset [3]) == 191) { |
30 |
$rest = substr ( $contents , 3); |
31 |
rewrite ( $filename , $rest ); |
32 |
return ‘<font color=red>BOM found,automatically removed.</font>‘ ; |
34 |
return ‘<font color=red>BOM found.</font>‘ ; |
37 |
return ‘BOM Not Found.‘ ; |
41 |
function rewrite ( $filename , $data ) { |
42 |
$filenum = fopen ( $filename , ‘w‘ ); |
43 |
flock ( $filenum , LOCK_EX); |
44 |
fwrite( $filenum , $data ); |
The contents of the head inside the HTML are parsed into the body by the browser.