2014-09-21 89 views
0

工作,我有在C在我的電腦PDF文檔:/xampp/htdocs/test.pdf如何使鏈接在本地主機/ HTML

我有聯繫這個文件(點擊此處) 在文件導航。 HTML也保存在htdocs中。

當我通過在localhost/nav.html中輸入地址欄來打開此文件時,該鏈接不起作用。但如果我通過在文件nav.html中雙擊打開它(在這種情況下,地址欄顯示file:/// C:/xampp/htdocs/nav.html),則鏈接將起作用。

如何使鏈接在前一種情況下激活。

+0

最有可能的Apache要麼不運行或配置爲偵聽非標準端口(非80端口) – AlliterativeAlice 2014-09-21 06:00:35

+1

是你的apache服務器運行..(wamp或xampp或其他)? – adi 2014-09-21 06:02:18

+0

你是如何鏈接的? – Himal 2014-09-21 06:04:02

回答

0
  • 使用relatve路徑<a href="test.pdf" title="pdf">(click here)</a>

  • 確保有關test.pdf文件和nav.html位於同一個文件夾c:/xampp/htdocs/

  • 如果您nav.html頁面加載不與你的本地主機/ nav.html所以你必須檢查apache服務狀態和測試端口80

  • 檢查文件c:\ X中的文檔根目錄AMPP \ apache的\的conf \ httpd.conf中

    DocumentRoot c:/users/farshad/documents/web/ 
    <Directory /> 
         Options FollowSymLinks 
         AllowOverride None 
    </Directory> 
    
    <Directory c:/users/farshad/documents/web/> 
         Options Indexes FollowSymLinks MultiViews 
         AllowOverride None 
         Order allow,deny 
         allow from all 
    </Directory> 
    

爲@Monsieur蒂諾建議

0

Ohai, 嘗試從另一個計算機例如192.168.1連接,並進入到你的服務器的鏈接(。 XX用路由器歸屬的編號替換XX)。然後,測試你是否可以去你的pdf。如果它不工作,嘗試(我猜你的DocumentRoot是C:// XAMMP):

<a href="/htdocs/test.pdf" title="test">Behind this link, there's a pdf</a> 
+0

這不會work.web root位於'/ htdocs /'你必須使用@Farshad建議的相對路徑或使用'http:// localhost/test.pdf' – Himal 2014-09-21 06:13:25

+0

對不起,我在我的服務器上使用Debian ,不知道它如何在Windows上運行。 – 2014-09-21 06:19:00