2016-06-22 48 views
0

我有一個codeigniter項目。我需要將其提交給Google網站管理員工具,爲此我必須將XML格式的網站地圖提交給Google。 Soe我在我的本地主機上創建了一個動態站點地圖生成腳本(Xampp 3.2.2)。所有的都很好,我得到這個XML瀏覽器中呈現:XML解析錯誤預計:</link>

<?xml version="1.0" encoding="UTF-8"?> 
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 
       http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> 
    <url> 
     <loc>http://localhost/moulana_online/site/home</loc> 
     <lastmod>2016-03-03T10:27:22-08:00</lastmod> 
     <changefreq>hourly</changefreq> 
     <priority>0.8</priority> 
    </url> 

    <url> 
     <loc>http://localhost/moulana_online/site/about-us</loc> 
     <lastmod>2015-11-22T00:41:38-08:00</lastmod> 
     <changefreq>hourly</changefreq> 
     <priority>0.8</priority> 
    </url> 

    <url> 
     <loc>http://localhost/moulana_online/site/our-mission</loc> 
     <lastmod>2015-11-22T01:24:30-08:00</lastmod> 
     <changefreq>hourly</changefreq> 
     <priority>0.8</priority> 
    </url> 

    <url> 
     <loc>http://localhost/moulana_online/site/moulana-dr-nabi-raza-abidi</loc> 
     <lastmod>2015-11-30T17:29:32-08:00</lastmod> 
     <changefreq>hourly</changefreq> 
     <priority>0.8</priority> 
    </url> 

    <url> 
     <loc>http://localhost/moulana_online/site/contact-us</loc> 
     <lastmod>2015-11-16T03:00:53-08:00</lastmod> 
     <changefreq>hourly</changefreq> 
     <priority>0.8</priority> 
    </url> 
</urlset> 

但只要我上傳我的腳本生活網站(http://www.moulanaonline.com/sitemap)主辦IIS服務器上。它給了我這個錯誤:

XML Parsing Error: mismatched tag. Expected: </link>. 
Location: http://www.moulanaonline.com/sitemap 
Line Number 69, Column 3: 
</head> 
--^ 

我仍然無法弄清楚這一點。任何幫助,將不勝感激。

+1

您提供的xml不是您正在使用的xml,因爲它甚至沒有'69'行。請用正確的數據更新問題。 – Rao

回答

0

錯誤消息顯然是指您發佈的不同文件。您可以通過提及第69行的錯誤消息來看到它,它表示它讀取的是</head>,而您發佈的文件只有40行。

因此,無論您的上傳是錯誤的還是服務器意味着另一個文件。

+0

感謝您的回答。我認爲這可能是IIS服務器上的目錄瀏覽問題。由於我無法直接在瀏覽器中訪問文件(不知道爲什麼),我的站點地圖控制器可能無法在瀏覽器中找到正確的xml文件。另一方面,我的本地主機並不是這種情況,我可以直接訪問文件。你說什麼? – Ali

+0

原來,我的IIS服務器不允許請求.xml文件。 – Ali

0

我自己修復了。這是IIS服務器上的文件請求問題。 IIS服務器不允許請求任何.XML文件,並且正在生成404未找到的錯誤。這導致我的站點地圖生成腳本無法加載正在動態創建正確的XML文件。在以下指令中添加了xml web.config

<rule name="Rewrite CI Index"> 
    <match url=".*" /> 
     <conditions> 
     <add input="{REQUEST_FILENAME}" pattern="woff|ttf|svg|css|js|jpg|jpeg|png|gif|ico|htm|html|xml" negate="true" /> 
     </conditions> 
     <action type="Rewrite" url="index.php/{R:0}" /> 
</rule>