开发者

Make multiple document roots?

I currently have my document root be the htdocs directory. Inside of that I have 开发者_开发知识库files relating to my domain name (index.html, style, everything) we will call this Site. Also in htdocs there is a directory called MT. This needs to stay here or else everything in Site gets messed up. So everything is great except that in order to see my website I have to do example.com/Site/index.html .... that is no good because I want to just do example.com. So I thought ok change the document root to htdocs/Site. That works but then I do not have access to changing my Movable Type interface. And I cannot move this directory from were it is.

I want to be able to say htdocs/Site is my document root and it will be example.com and have example.com/MT work as well without moving any directories around. Is that possible?


If you have access to the filesystem, you should look into symbolic links:

man ln

 ln -s htdocs/MT htdocs/site/MT

This will create a symbolic link called MT in the directory htdocs/site/MT that refers to htdocs/MT ... note if you are using apache, you'll need to ensure it has the appropriate configuration to follow the symbolic links.


Assuming you have mod_rewrite enabled...

Create a .htaccess file in your Document Root, in it place the following:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/(MT|Site) [nc]
RewriteRule ^(.*)$ http://www.example.com/Site/$1 [r=301,L]

This will redirect all requests to the /Site folder except requests for the /MT folder. It's automatic, practically invisible to the visitor and nice all around.

This will also allow people do get to your site from the base domain.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜