2010-07-04 97 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聲明,但沒有運算符優先級,所以它只是從上到下進行評估,這在這裏不起作用。