2012-02-08 63 views
3

我想讓FuelPHP在我的服務器上工作。我無法使用RewriteRule的.htaccess文件。但是,我的主機允許我指定httpd.conf文件的一部分。帶有Apache目錄和RewriteRule的通配符?

以下作品我想要的東西:

<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/username/public> 
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</Directory> 

不過,我需要它比在那裏只是「用戶名」更多的工作。 如何在此目錄中使用通配符,以便它適用於一次性解決方案的任何「用戶名」值?

我在apache manual上發現了此建議,但我不確定如何使它與RewriteRule一起使用。

試過以下,但它沒有工作:

<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public> 
    RewriteEngine on 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</Directory> 

請幫幫忙!

回答

5

你是密切與Apache手冊:

<Directory /Applications/XAMPP/xamppfiles/htdocs/sandbox/*/public> 

<Directory ~ "/Applications/XAMPP/xamppfiles/htdocs/sandbox/.*/public"> 
+0

你能告訴什麼是錯在這句法。我得到了禁止消息: 別名/ salt「/var/cache/salt/master/minions/.*/files」 選項MultiViews關注鏈接 需要全部授權 – 2016-08-17 20:02:37

1

我們發現這個消息是解決我們出現了問題,有沒有提供真正的解決方案:How to use apache2 mod_rewrite within a Directory directive that uses wildcards?

我們結束了使用下述溶液:

RewriteEngine On 

RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f 
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d 

RewriteRule ^(/sandbox/([^/]*)/public/.*)$ /sandbox/$2/public/index.php?$1 [PT,QSA] 

的「PT」必須增加,因爲它通常隱含在目錄塊中,並告訴它將目標路徑作爲URI而不是文件路徑(由於它沒有獲得完整的本地路徑,所以這不起作用)。 QSA標誌只是確保你的index.php得到最初提交的所有信息。