我有一个管理路由的Marionette应用程序,但我不希望它处理它们以获取对server.com/api/anything/at/all的api调用请求
我的规则此刻看起来像这样,但是Marionette似乎总是抓住它,即使它是/ 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位于我的/ public文件夹中。在根文件夹中我有:
# ------------------------------------------------------------------------------
# | Phalcon |
# ------------------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]
</IfModule>
公共重写工作正常。我只是觉得我会分享它,以防它影响公众中我没想到的那个。谢谢!
答案 0 :(得分: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>