开发者

Make Apache to show different index.html also in browser's address bar

I have the following foloder tree on my shared hosting server:

www.somesite.com
|
|_ public_html (document folder开发者_C百科)
    |_ .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.

Now when someone looks for www.somesite.com the webserver look for index.html in public_html folder.

  1. I would like the web server to show website/index.html when someone looks for www.somesite.com and I would like his browser bar to show only www.somesite.com/index.html and not www.somesite.com/website/index.html

  2. I would also like the web server to show site_editor/login.html when someone looks for www.somesite.com/site_editor/

Is it possible to accomplish both task by setting .htaccess files in some ways???

Thanks!


If I understood correctly, the following should work, although I didn't really test it:

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

People could still go to www.somesite.com/website/index.html if they wanted to though. I think there may be a fix for that, but because of how the .htaccess RewriteRules are applied it's tricky to get right. If I remember what it is I'll update my answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜