2014-11-15 43 views
1

我有一個管理路線木偶應用程序,但我不希望它處理他們的API調用請求server.com/api/anything/at/all的.htaccess規則就好像忽略了

我的規則看起來像這在當下,但木偶似乎總是追趕它,即使它是/ API/*

# ------------------------------------------------------------------------------ 
# | Marionette                 | 
# | If it's not for /api/*, then handle it          | 
# ------------------------------------------------------------------------------ 

<ifModule mod_rewrite.c> 
    DirectorySlash Off 
    RewriteEngine On 
    RewriteCond %{THE_REQUEST} ^.*/index.php 
    RewriteCond %{REQUEST_URI} !^/api/ [NC] 
    RewriteRule ^(.*)index.php $1 [R,L] 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_URI} !^/index\.php 
    RewriteRule (.*) index.php 
</ifModule> 
# ------------------------------------------------------------------------------ 
# | Phalcon                 | 
# | If it fell through, handle with Phalcon         | 
# ------------------------------------------------------------------------------ 

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L] 
</IfModule> 

誰能告訴我什麼,我做了錯誤請在這裏?謝謝。

編輯:如果它給出任何清晰度,上述.htaccess是在我的/公共文件夾。在根文件夾中,我有:

# ------------------------------------------------------------------------------ 
# | Phalcon                 | 
# ------------------------------------------------------------------------------ 

<IfModule mod_rewrite.c> 
    RewriteEngine on 
    RewriteRule ^$ public/ [L] 
    RewriteRule (.*) public/$1 [L] 
</IfModule> 

公共重寫工作正常。我只是認爲我會分享它,以防其中一些事情影響了我沒有想到的公開內容。謝謝!

回答

0

Marionette規則應該是這樣的:

<ifModule mod_rewrite.c> 
    DirectorySlash Off 
    RewriteEngine On 
    RewriteCond %{THE_REQUEST} ^.*/index.php 
    RewriteCond %{REQUEST_URI} !^/api/ [NC] 
    RewriteRule ^(.*)index.php $1 [R,L] 

    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{THE_REQUEST} !\s/+(index\.php|api/) [NC] 
    RewriteRule^index.php [L] 
</ifModule> 
+0

我代替我的塊與你和我仍然得到同樣的答覆。 server.com/ - Marionette server.com/api/ - Marionette server.com/api/test - Marionette – Drew

+0

是的,工作 - 謝謝。有關如何確保它僅適用於server.com/api/x/y/z的任何想法?我使用server.com/marionette/api/進行了測試,並且因爲它包含'api',它通過規則感受到了phalcon。所以我打算讓規則說/ api /在開始? – Drew

+0

我調整了規則,只在開始時進一步匹配'/ api /'。 – anubhava