Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.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
Php mod_rewrite不适用于jQuery.ajax_Php_Jquery_Ajax_.htaccess_Mod Rewrite - Fatal编程技术网

Php mod_rewrite不适用于jQuery.ajax

Php mod_rewrite不适用于jQuery.ajax,php,jquery,ajax,.htaccess,mod-rewrite,Php,Jquery,Ajax,.htaccess,Mod Rewrite,我正在使用WAMP、jQuery和CodeIgniter。我已经创建了.htaccess来删除index.php,它工作正常 但是使用$.ajax是行不通的。它必须使用index.php进行访问。我做错了什么 这是.htaccess文件 <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FI

我正在使用WAMP、jQuery和CodeIgniter。我已经创建了.htaccess来删除index.php,它工作正常

但是使用$.ajax是行不通的。它必须使用index.php进行访问。我做错了什么

这是.htaccess文件

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>

谢谢。

在现有规则之前添加此规则

RewriteRule ^(index\.php/(.+)$ $1?/$2 [L,NC,QSA]

在这条规则中,
RewriteRule^(.*)$index.php?/$1[L]
我认为您需要将
index.php?/$1
替换为
index.php/$1
,这是根据您的评论调整后的htaccess。我做错了什么?RewriteBase/RewriteCond%{REQUEST_FILENAME}上的RewriteEngine-f RewriteCond%{REQUEST_FILENAME}-重写规则^(index\.php/(.+)$$1?/$2[L,NC,QSA]重写规则^(.*)$index.php?/$1[L]对于哪个URL它不起作用,您得到的是404吗?URL是“”。除了使用$.ajax调用外,其他都可以正常工作。它返回错误状态,但没有找到描述。使用index.php它可以正常工作。非常感谢您的友好支持。很抱歉,我的英语很差。使用$.ajax()调用时,它不可以正常工作,我需要用index.php设置url。这让我想知道,直接访问调用和$.ajax()的GET方法有什么区别。
RewriteRule ^(index\.php/(.+)$ $1?/$2 [L,NC,QSA]