【发布时间】:2013-02-25 12:16:33
【问题描述】:
我在 Wordpress 中创建了一个新页面。在此页面上,我放置了以下 HTML 代码:
Please click this <a href="http://sitename.com/blog/wp-content/themes/twentytwelve/statistics.php" title="link">link</a> to view the details.
statistics.php 包含查询后端 MySQL 数据库、获取详细信息并以表格格式显示的代码。
但是,当我点击 Wordpress 页面上的链接时,我会收到一条 403 禁止消息。
Forbidden
You don't have permission to access /blog/wp-content/themes/twentytwelve/statistics.php on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
我已尝试将 PHP 文件的权限设置为 644 和 755。错误仍然存在。
我什至尝试在 PHP 文件中添加这样的简单代码:
<?php echo "welcome"?>
即便如此,同样的 403 禁止错误。
现在,我在这个 Wordpress 网站上有另一个页面。在该页面中,我有一个 HTML 表单,它向名为 process.php 的 PHP 文件发送 POST 请求,该文件与 statistics.php 位于同一目录中。该页面可以正常工作。
因此,我尝试将新页面中的 URL 从 statistics.php 替换为 process.php。这不会给出 403 禁止错误。
为什么我无法从我的 wordpress 页面访问一个 PHP 文件?我可以只从 wordpress 页面链接到一个外部 PHP 文件吗?
statistics.php 和 process.php 具有相同的权限。然而,虽然一个页面能够轻松访问 process.php,但另一个页面却给出了 statistics.php 的错误。
我们将不胜感激。
谢谢。
【问题讨论】:
-
您是否检查过您的 .htaccess 文件中是否存在任何过于全局定义的 RewriteRules?在任何情况下...您都应该检查服务器日志文件,以准确了解当您尝试打开页面时会发生什么。