Ajax 和 Htaccess 的 URL 不匹配


URL mismatch for Ajax and Htaccess

我重写了一个htaccess,但不知何故,我的ajax调用从未到达控制器中的相应功能。相反,从 buglite 控制台,它显示所有 HTML 代码。我正在写代码点火器,我对这件事完全筋疲力尽。请帮忙!

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

在视图中,附加了javascript。

$('#logoutbtn').click(function(){
         $.ajax({
            type:"POST",
            url: "/fbcontroller/killsession",
            datatype: "json",
            success: function(){
                alert("Logout");
            }
         });
    });

错误显示在 buglite 中。

POST /fbcontroller/killsession 404 Not Found 416ms  

供您参考,

我可以直接访问http://localhost/fbcontroller/killsession

由于正则表达式错误,此规则似乎有问题:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)'?*$ index.php/$1 [L,QSA]

这是试图匹配 0 个或多个实例的文字?. ?在 中不匹配

将该规则替换为:

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