1

我的共享托管服务器上有以下文件夹树:

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 时,网络服务器会在 public_html 文件夹中查找 index.html。

  1. 我希望网络服务器website/index.html在有人查找 www.somesite.com 时显示,我希望他的浏览器栏只显示www.somesite.com/index.html而不显示www.somesite.com/website/index.html

  2. 我还希望网络服务器在有人查找时显示site_editor/login.htmlwww.somesite.com/site_editor/

是否可以通过以某种方式设置 .htaccess 文件来完成这两项任务???

谢谢!

4

1 回答 1

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 的应用方式,很难做到正确。如果我记得它是什么,我会更新我的答案。

于 2010-06-16T15:09:09.963 回答