2016-09-14 28 views
1

我在Angular 2上提供角度爲2的應用程序。在主機上,它位於文檔根目錄下,一切工作正常。我有一個.htaccess文件:Apache服務器上的Angular 2應用程序

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/
    RewriteRule ^index\.html$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.html [L]  
</IfModule> 

問題: 我的筆記本電腦,我有一個Apache服務器(XAMPP)與文檔根目錄爲「 C:\用戶\ WebProjects

當我開發的網站,我把文件在c:\ users ... \ Projects \ Projects1 \ dist 在這個目錄中,我不能讓網站工作,因爲文件/文件夾不在根目錄。試圖加載\ css \ app.css,當它應該加載Projects1 \ dist \ css \ app.css

我可以寫一個特定的.htacc是否可以從該目錄提供應用程序? (?或無需改變的httpd.conf文件根別的東西)

感謝

回答

0

您需要添加在你的.htaccess文件和您的index.html文件的路徑,像這樣:

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /your/path/here/ 
    RewriteRule ^index\.html$ - [L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule . /index.html [L]  
</IfModule> 

index.html中,您需要更新藏漢基本HREF反映,像這樣的路徑:

<base href="/your/path/here/">

而且應該做的T裏克:)

相關問題