【问题标题】:ajax files affected by .htaccess受 .htaccess 影响的 ajax 文件
【发布时间】:2015-06-08 13:37:52
【问题描述】:

这是我的 .htaccess 文件:

# Turn rewrite engine on
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

### Rewrite url ###
# Basic rewrite for pages in the admin area
RewriteRule ^admin/([^/]*)/([^/]*)$ /private/admin/index.php?plugin=$1&page=$2 [L,QSA]

还有我的javascript:

$(document).ready(function() {
    var $post = '/private/admin/js/ajax.php';
    $('#email').keyup(function() {
    $.post($post, {email_valid : val}, function(answer) {
                    console.log(answer); // Another pot after this, depending on the answer
   }
});

假设我在 domain.com/admin/users/register 中,我想检查电子邮件是否有效或是否已与 PHP 一起使用。

当我像上面一样拥有$post 时,我收到以下错误:POST domain/private/admin/js/ajax.php 500 (Internal Server Error);

更新 整个 500 错误:

POST http://domain.com/private/admin/js/ajax.php 500 (Internal Server Error)
n.ajaxTransport.k.cors.a.crossDomain.send @ jquery.js:8630
n.extend.ajax @ jquery.js:8166
n.each.n.(anonymous function) @ jquery.js:8311(anonymous function) @ lr.js:41
n.Callbacks.j @ jquery.js:3099
n.Callbacks.k.fireWith @ jquery.js:3211
x @ jquery.js:8264
n.ajaxTransport.k.cors.a.crossDomain.send.b @ jquery.js:8605

lr.js:41是其他帖子出现的地方,但基本相同,只是帖子名称不同。

当我将路径更改为:/admin/js/ajax.php 时,我收到错误消息:The plug-in: js and or the page: ajax.php don't exists。此错误消息位于我包含其他文件的管理文件夹的 index.php 中。我知道 ajax.php 文件像我以前使用过的那样工作。在我使用 .htaccess 文件之前它确实有效。

文件结构:

在我问这个之前我已经检查了其他问题:

我希望有人可以帮助我解决这个问题。提前致谢

【问题讨论】:

  • 您的错误日志对 500 错误有何看法?
  • @JonLin 更新了错误输出
  • @anubhava 我得到一个空白页,源代码中也没有任何内容
  • 我的意思是 apache 错误日志。在服务器端。
  • @SuperDJ 我敢打赌你有语法错误或另一个 PHP 错误。通常为什么你会得到一个空白页。您必须有权访问 error_logs,因为没有它们就不可能进行故障排除。而不是试图猜测。让您的主机为您的特定站点提供错误日志。他们可以做到。

标签: php ajax .htaccess


【解决方案1】:

/private/ 文件夹中试试这个.htaccess:

Options -MultiViews
RewriteEngine on
RewriteBase /private/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Basic rewrite for pages in the admin area
RewriteRule ^admin/([^/]+)/([^/]+)/?$ admin/index.php?plugin=$1&page=$2 [L,QSA,NC]

【讨论】:

  • 那么我想你别无选择,只能与你的服务器管理员联系,让你访问 Apache error.log
  • 我可以访问 apache 错误日志,但没有发现指向此问题的错误。
  • 对于任何 500,Apache error.log 中总会有一些东西
猜你喜欢
  • 1970-01-01
  • 2016-06-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多