2010-06-16 114 views
1

我有我的共享主機服務器上的以下foloder樹:讓Apache以顯示不同的index.html也是在瀏覽器的地址欄中

www.somesite.com 
| 
|_ public_html (document folder) 
    |_ .htaccess (Apache file) 
    |_ index.html (page shown by server now when someone looks for www.somesite.com) 
    | 
    |_ site_editor (folder) 
    | |_login.html (site editor control panel) 
    | |_file1.php 
    | |_file2.php 
    | |_ ... 
    | 
    |_ website (folder) 
     |_ index.html (website HOME PAGE) 
     |_ page1.html 
     |_ page2.html 
     |_ etc. 

現在,當有人查找www.somesite.com Web服務器查找指數.html在public_html文件夾中。

  1. 我想網絡服務器顯示website/index.html當有人查找www.somesite.com,我想他的瀏覽器欄只顯示www.somesite.com/index.html,而不是www.somesite.com/website/index.html

  2. 我會也就像web服務器到顯示site_editor/login.html當有人找www.somesite.com/site_editor/

是否有可能通過以某種方式設置.htaccess文件來完成這兩項任務?

謝謝!

回答

0

如果我理解正確,下面應該工作,雖然我並沒有真正測試:

RewriteEngine On 
RewriteBase/
# Rewrite everything that's not site_editor or already rewritten 
# to the website folder 
RewriteRule !^site_editor(/.*)?$ -   [C] 
RewriteRule !^website(/.*)?$  -   [C] 
RewriteRule ^(.*)$    website/$1 [PT,QSA,L] 
# Rewrite a request to site_editor/ to site_editor/login.html 
RewriteRule ^site_editor/$  site_editor/login.html 

人們仍然可以去www.somesite.com/website/index.html如果他們想雖然。我認爲可能有一個解決方案,但由於如何應用.htaccess RewriteRules,很難得到正確的答案。如果我記得它是什麼,我會更新我的答案。

相關問題