The contents of the head inside the HTML are parsed into the body by the browser.

Source: Internet
Author: User
Tags ord

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)

01 <?php
02 $basedirstr_replace(‘/clearBOM.php‘,‘‘,str_replace(‘\\‘,‘/‘,dirname(__FILE__)));
03 $auto= 1;
04 checkdir($basedir);
05 functioncheckdir($basedir){
06     if($dh= opendir($basedir)) {
07         while(($file= readdir($dh)) !== false) {
"    ;            if   $file  !=&NBSP;  &&  $file   != 
"    ;                if   (! is_dir $basedir '/' $file
ten    ;                   $filename   $ Basedir '/' $file
one    ;                   echo   $basedir '/' $file .checkbom ( $filename ' <br> '
12                 else{
13                     $dirname$basedir.‘/‘.$file;
14                     checkdir($dirname);
15                 }
16             }
17         }
18         closedir($dh);
19     }
20 }
21
22 functioncheckBOM ($filename) {
23     global$auto;
24     $contentsfile_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) {
29         if($auto== 1) {
30             $restsubstr($contents, 3);
31             rewrite ($filename$rest);
32             return‘<font color=red>BOM found,automatically removed.</font>‘;
33         else{
34             return‘<font color=red>BOM found.</font>‘;
35         }
36     else{
37         return‘BOM Not Found.‘;
38     }
39 }
40
41 functionrewrite ($filename$data) {
42     $filenumfopen($filename‘w‘);
43     flock($filenum, LOCK_EX);
44     fwrite($filenum$data);
45     fclose($filenum);
46 }
47 ?>

The contents of the head inside the HTML are parsed into the body by the browser.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.