2014-10-02 33 views
-3

正如您所看到的,在下面的代碼中,它會再次動態調用自身,並在單擊按鈕(通過PHP包含)時更改頁面上的內容。這會傷害搜索引擎優化還是像Google這樣的公司能夠足夠聰明地注意到文件可以包含在這裏然後去查找目錄中的其他文件?帶有PHP的SEO包含開關語句(因此頁面像JavaScript一樣動態變化)

<!DOCTYPE html> 
<html> 
<head> 
    <title>Web Template</title> 
</head> 
<body> 
    <?php include ("inc_header.html"); ?> 
    <div style = "width:20%; text-align:center; float:left"> 
     <?php include ("inc_buttonnav.html"); ?> 
    </div> 
    <!-- Start of Dynamic Content section --> 
    <?php 
    if (isset($_GET['content'])) { 
     switch ($_GET['content']) { 
      case 'About Me': 
       include('inc_about.html'); 
       break; 
      case 'Contact Me': 
       include('inc_contact.html'); 
       break; 
      case 'Home': // A value of 'Home' means to display the default page 
      default: 
       include('inc_home.html'); 
       break; 
     } 
    } 
    else // No button has been selected 
     include('inc_home.html'); 
    ?> 

<!-- End of Dynamic Content section --> 

<?php include ("inc_footer.php"); ?> 

</body> 
</html> 

好的,我沒有看過瀏覽器解析的代碼。以下是瀏覽器看到的主頁和關於

主頁:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Web Template</title> 
</head> 
<body> 
<h1 style="text-align: center">Sample Web Template</h1> 
<div style = "width:20%; text-align:center; float:left"> 
    <form action="WebTemplate.php" method="get"> 
     <input type="submit" name="content" value="Home" /><br /> 
     <input type="submit" name="content" value="About Me" /><br /> 
     <input type="submit" name="content" value="Contact Me" /><br /> 
    </form> 
</div> 

<!-- Start of Dynamic Content section --> 

<h2>Home Page</h2> 
<p>This is the default home page that displays 
whenever a new visitor comes to the site</p> 

<!-- End of Dynamic Content section --> 

<p>Today's Date: Tue, 21 Oct 2014 05:42:41 +0000</p></body> 
</html> 

關於:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Web Template</title> 
</head> 
<body> 
<h1 style="text-align: center">Sample Web Template</h1> 
<div style = "width:20%; text-align:center; float:left"> 
    <form action="WebTemplate.php" method="get"> 
     <input type="submit" name="content" value="Home" /><br /> 
     <input type="submit" name="content" value="About Me" /><br /> 
     <input type="submit" name="content" value="Contact Me" /><br /> 
    </form> 
</div> 

<!-- Start of Dynamic Content section --> 

<h2>About Me</h2> 
<p>This is the page that tells about me and my Web 
site.</p> 

<!-- End of Dynamic Content section --> 

<p>Today's Date: Tue, 21 Oct 2014 05:43:02 +0000</p></body> 
</html> 

我想這將是特別緻密堅硬遵循Googlebot抓取。我想我可以嘗試依靠一個好的網站地圖,但也許只是有一個更簡單的網站會更好。

+0

由於PHP在服務器端處理,爬蟲爬取客戶端,可以這麼說,爬蟲只能'知道'當前的情況。 – 2014-10-02 19:26:13

+0

Google無法看到您的PHP。它將URL和生成的內容置疑。所以如果你的鏈接是唯一的(domain.com/home&domain.com/about),但它們都是從一個PHP腳本生成的,Google不會知道或關心。許多CMS產品都使用這種方法。我建議不要使用以下鏈接:domain.com/index.php?content=main雖然。這似乎不是一個好習慣。 – DragonYen 2014-10-02 19:28:30

回答

0

您的網頁有不同的URL,如:

http://www.example.net/mypage.php?content=about 
http://www.example.net/mypage.php?content=contact 
http://www.example.net/mypage.php?content=home 

大多數搜索引擎把這些作爲potentionally不同的頁面。 當他們加載他們,他們是不同的,那麼他們將被視爲不同。

+0

好的,如果我有一個好的網站地圖文件,它應該不是真的有問題嗎? – 2014-10-03 05:11:21

+0

是的,這不是問題。 – 2014-10-03 07:02:06