2017-02-04 150 views
2

這很可能是初學者的問題,但我似乎無法在任何地方找到修復程序,我發現處理它的幾篇文章未得到答覆(例如xampp in window 7 cannot access files in subfolder inside C:/xampp/htdocs)。XAMPP:在根目錄的子目錄中訪問html頁面

到目前爲止,我有一個使用XAMPP的工作本地主機(必須將端口更改爲8080),位於自定義文檔根目錄中。我可以加載index.html的,但是當我點擊一個鏈接向subdirectoy:

<li><a href="examples/test.html"></a></li> 

我得到以下錯誤:

Service unavailable!

The server is temporarily unable to service your request due to maintenance downtime or capacity problems. Please try again later.

If you think this is a server error, please contact the webmaster.

Error 503

localhost Apache/2.4.25 (Win32) OpenSSL/1.0.2j PHP/5.6.30

即使我在地址(http://localhost:8080/examples/test.html)直接鍵入在瀏覽器中,它也不起作用。

有人請指出這是否應該工作?或者,如果我應該在Apache配置文件中指定一些東西?

我還可以注意到,當瀏覽器(在本地主機之外)瀏覽html文件時,無論頁面在目錄中的位置如何,頁面都可以正常工作並加載。謝謝你的幫助!

編輯: 這是我修改的conf文件的DocumentRoot部分:

#DocumentRoot "F:/Apps/xampp/htdocs" 

DocumentRoot "F:/me/GitWorkDir/myproject_io" 


<Directory "F:/me/GitWorkDir/myproject_io"> 
    # 
    # Possible values for the Options directive are "None", "All", 
    # or any combination of: 
    # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews 
    # 
    # Note that "MultiViews" must be named *explicitly* --- "Options All" 
    # doesn't give it to you. 
    # 
    # The Options directive is both complicated and important. Please see 
    # http://httpd.apache.org/docs/2.4/mod/core.html#options 
    # for more information. 
    # 
    Options Indexes FollowSymLinks Includes ExecCGI 

    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # AllowOverride FileInfo AuthConfig Limit 
    # 
    AllowOverride All 

    # 
    # Controls who can get stuff from this server. 
    # 
    Require all granted 
</Directory> 
+1

你做任何在conf文件中修改documentRoot? –

+0

是的,我確實更改了DocumentRoot目錄(請參閱原始文章中的編輯)。這能解釋這個問題嗎?因爲據我所知,即使在新的根目錄中,本地主機也可以訪問index.html,而不是在子目錄中。 – sc28

回答

1

事實證明,這個問題是由於一個不幸的巧合導致子目錄無法被調用,恰恰是「示例」... 請參閱此page討論該問題並提出修復建議。

總之,你可以:

  1. 要麼去到文件C:\ XAMPP的\ apache的\的conf \額外\的httpd-ajp.conf 並添加 「#」 註釋掉衝突行: 的ProxyPass /例子AJP://127.0.0.1:8009 /例子SMAX = 0 TTL = 60重試= 5
  2. 或者乾脆重新命名不同的 「實例」 的目錄(如examples2)
+0

如果你改變你的docuementroot然後XAMPP將開始尋找改變的目錄裏面不是在htdocs(記得在Windows中,你需要給用戶許可,最簡單的是「所有人」組)。這是非常簡單的問題,我一直試圖告訴你,但可能是我的英文不夠清楚 –

1

晴,如果你在Windows上安裝XAMPP它運行沒有任何問題。只有對Windows發出問題的東西是許可。您可以通過右鍵單擊htdocs文件夾並轉到安全選項卡並向所有人授予所有權利。

+0

謝謝,我在「安全」選項卡中添加了完全控制,但訪問子目錄文件時仍會出現錯誤503。但我認爲根據你的信息,我正面臨一個意想不到的行爲吧?它應該工作沒有問題?如果你有任何其他的想法可以解決這個問題,請不要猶豫分享... – sc28

+0

然後你已經授權給你爲文件根目錄設置的文件夾給用戶「Everyone」 –

+0

請給右爲此文件夾的「所有人」用戶F:/ me/GitWorkDir/myproject_io 現在這是您的web文件夾,您可以訪問其子文件夾而不是默認htdocs的子文件夾 –