[英]Make Apache to show different index.html also in browser's address bar
I have the following foloder tree on my shared hosting server: 我的共享托管服务器上有以下foloder树:
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.
Now when someone looks for www.somesite.com the webserver look for index.html in public_html folder. 现在,当有人在寻找www.somesite.com时,网络服务器将在public_html文件夹中寻找index.html。
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
当有人寻找www.somesite.com时 ,我希望Web 服务器显示
website/index.html
,我希望他的浏览器栏仅显示www.somesite.com/index.html
,而不显示 www.somesite.com/website/index.html
I would also like the web server to show site_editor/login.html
when someone looks for www.somesite.com/site_editor/
当有人寻找
www.somesite.com/site_editor/
时,我还希望Web服务器显示site_editor/login.html
。
Is it possible to accomplish both task by setting .htaccess files in some ways??? 是否可以通过以某些方式设置.htaccess文件来完成这两项任务?
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. 如果愿意,人们仍然可以访问www.somesite.com/website/index.html。 I think there may be a fix for that, but because of how the .htaccess RewriteRules are applied it's tricky to get right.
我认为可能对此有解决方法,但是由于.htaccess RewriteRules的应用方式,要正确就很棘手。 If I remember what it is I'll update my answer.
如果我记得是什么,我将更新我的答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.