Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Apache'时出现问题;s mod_重写_Apache_Mod Rewrite - Fatal编程技术网

使用Apache'时出现问题;s mod_重写

使用Apache'时出现问题;s mod_重写,apache,mod-rewrite,Apache,Mod Rewrite,My webroot包含以下内容: 资产/ .htaccess handler.php index.html main.js style.css 我在我的main.js $.ajax({ url: "api/example.php", type: "GET", dataType: "json", cache: false, success: function(data) { console.log(data); } }); 我

My webroot包含以下内容:

  • 资产/
  • .htaccess
  • handler.php
  • index.html
  • main.js
  • style.css
我在我的
main.js

$.ajax({
    url: "api/example.php",
    type: "GET",
    dataType: "json",
    cache: false,
    success: function(data) {
        console.log(data);
    }
});
我的
.htaccess
看起来像这样

RewriteEngine On
RewriteRule ^api/(.*)$ handler.php?test=$1 [L]
然而,每次我发出AJAX请求时,我的控制台就会出现404错误,网络选项卡中的请求就会显示为红色

任何想法都将不胜感激,谢谢

谢谢!我的问题的解决办法就是改变

RewriteRule ^api/(.*)$ handler.php?test=$1 [L]


如果在重写规则中使用
/handler.php…
(带
/
)会发生什么情况?@DusanBajic是的,很有效,谢谢!
RewriteRule ^api/(.*)$ /handler.php?test=$1 [L]