2010-07-04 77 views
0

我为我的主机使用lunarages,并且可以添加多个网站。当我添加一个新的网站时,它会在我的当前网站存在的地方创建一个目录htaccess,主网站目录更改

即我的网站是jeffkilroy.com,如果我为hello.com创建域,它现在也存在于jeffkilroy.com/hello

这是好的,除了我想好了一些组织它,这样的网站目录不与我jeffkilroy.com文件

如果我把我所有的jeffkilroy.com站点文件在一些所谓的“主混“,是否有可能把东西在htaccess中:

jeffkilroy.com/home真的去jeffkilroy.com/main/home

,但仍然能够轻松地访问我的东西从根(其他网站): jeffkilroy.com/hello

回答

1

该解决方案完全取决于你在你的根没有文件夹(用于其他网站)与您的主站点中的文件夹名称相同,但由于您仍然希望能够从根目录访问其他站点的文件夹,因此没有太多办法。

无论如何,这似乎工作:

RewriteEngine On 

# Let's prevent them from being able to go to our /main path manually 
RewriteCond %{THE_REQUEST}  ^(POST|GET)\s/main 
RewriteRule ^main/?(.*)$ http://jeffkilroy.com/$1 [R,L] 

# Redirect stuff to /main/ if it isn't pointing to something else, or 
# if it's just pointing to the primary root 
RewriteCond %{REQUEST_URI}  ^/$ 
RewriteRule ^.*$ /main/$0 

RewriteCond %{REQUEST_URI}  !-f 
RewriteCond /main%{REQUEST_URI} -f 
RewriteRule ^.*$ /main/$0 

RewriteCond %{REQUEST_URI}  !-d 
RewriteCond /main%{REQUEST_URI} -d 
RewriteRule ^.*$ /main/$0 [L] 

旁注为好奇:这将是很好能够通过使用[OR]标志凝聚了RewriteCond声明,但没有运算符优先级,所以它只是从上到下进行评估,这在这里不起作用。