2010-09-23 53 views
1

1) 我有位於 http://example.com一個Drupal網站,我有一個目錄位於 http://example.com/foo,但我也有一個Drupal頁面的 http://example.com/foo的別名。我怎樣才能讓Drupal頁面服務?目前,由於Drupal的.htaccess文件中的 Options -Indexes聲明,我得到了403禁止頁面,但我不想刪除它,因爲我不希望目錄可瀏覽。 整蠱的.htaccess和Drupal問題

編輯:我已經解決了這個以下的規則:

RewriteCond %{REQUEST_FILENAME} -d 
RewriteRule ^(.*)$ http://localhost/s2k/index.php?q=$1 [L,QSA] 

2)爲了使問題更加困難,給予相同的情況下,如果我有一個index.html文件中的目錄http://example.com/foo/index.html我總是希望這個優先級高於Drupal的別名頁面(目前它是這樣做的 - 目前我已經修改了.htaccess文件,這樣任何帶有index.html文件的目錄都會顯示它 - DirectoryIndex index.php index.html)。

編輯:

所以,現在,我怎麼能寫的RewriteCond會看看,看看是否有是目錄內的index.html文件?

回答

2
RewriteCond %{REQUEST_FILENAME} -d 
RewriteCond %{REQUEST_FILENAME}/index.html !-f 
RewriteRule ^(.*)$ http://localhost/s2k/index.php?q=$1 [L,QSA] 
+0

什麼傳說。男人之間的國王。 – Finbarr 2010-09-29 17:41:02

+0

s2k目錄從哪裏來? – jsuggs 2010-09-29 21:11:00

3

我不是RewriteRule Guru,很確定有一個更好的方法來實現這一點,例如,有條件的RewriteCond。

但簡單地增加

RewriteCond %{REQUEST_URI} =/foo/ 
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] 

以上默認改寫Conds和規則,使這一規則踢在/富/,而不是Drupal的默認值。如果RewriteCond %{REQUEST_FILENAME} !-d將只應用RewriteRule,如果不是一個目錄。

+0

你啓發了一個解決問題的一部分 - 的感謝。第2部分的任何想法? – Finbarr 2010-09-29 17:13:28

0
RewriteCond %{REQUEST_FILENAME}index.html -f 
RewriteRule ^(.*)$ $1index.html [L] 

RewriteCond %{REQUEST_FILENAME}/index.html -f 
RewriteRule ^(.*)$ $1/index.html [L] 

[normal Drupal rewrite rules]