RewriteCond%{REQUEST_URI}!-d无效

时间:2016-03-20 18:46:13

标签: apache .htaccess mod-rewrite

这是我的.htaccess文件

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !-f
RewriteCond %{REQUEST_URI} !-d
RewriteCond %{REQUEST_URI} !-l

RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

我想将http://domain.com/index.php?url=controller重定向到http://domain.com/controller。现在它正常工作。但它不会跳过目录和文件。我做了一个index2.php文件。它还会重定向到index.php。

1 个答案:

答案 0 :(得分:1)

您在条件中使用了错误的变量。它不是REQUEST_FILENAME您需要检查的,RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)/?$ index.php?url=$1 [QSA,L]

$("button").click(function(){
  $.getJSON("my_array.php",function(data){
    $("#showdata").append(data.city);
  });
});
相关问题