我一整天都在为建立一个PHP/MySQL环境而挣扎,我想我最终会寻求帮助。
我已经启动并运行了XAMPP。为了在我喜欢的目录中工作,我用以下内容更新了/Applications/XAMPP/xamppfiles/etc/httpd.conf:
User MY_USERNAME
...
DocumentRoot "/Users/PATH/TO/WORKING/DIR/web"
<Directory "/Users/PATH/TO/WORKING/DIR/web">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/trunk/mod/core.html#options
# for more information.
#
#Options Indexes FollowSymLinks
# XAMPP
Options Indexes FollowSymLinks ExecCGI Includes
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
#AllowOverride None
# since XAMPP 1.4:
AllowOverride All
#
# Controls who can get stuff from this server.
#
Require all granted
</Directory>否则,我的httpd.conf设置就是XAMPP默认值。在我的web dir中,我有index.php:
<?php
require_once __DIR__."/../vendor/autoload.php";
$app = new Silex\Application();
$app->get("/", function () {
return "Hello World";
});
$app->get("/test", function () {
return "Success";
});
$app->run();
?>如果我去localhost,我会得到预期的"Hello“。然而,如果我去localhost/test,我得到:
对象找不到! 在此服务器上找不到请求的URL。如果您手动输入了URL,请检查拼写,然后重试。 如果您认为这是服务器错误,请与网站管理员联系。 错误404 localhost Apache/2.4.23 (Unix) OpenSSL/1.0.2h PHP/5.6.24 mod_perl/2.0.8-dev Perl/v5.16.3
这是一个非常简单的例子,但说明了这个问题。
我已经搜索了Google的结果,找出了这个错误,但是推荐的建议都没有帮助:
.htaccess,但我不知道XAMPP在哪里,也不知道应该在哪里创建它,也不知道应该在其中放入什么内容或它是什么。AllowOverride None改为AllowOverride All in httpd.conf的建议似乎行不通。(确认没有帮助后,我将其恢复到默认设置)任何帮助都将不胜感激!耽误您时间,实在对不起!
溶液
我在/Users/PATH/TO/WORKING/DIR/todo中创建了XAMPP,我需要将它放在/Users/PATH/TO/WORKING/DIR/todo中的XAMPP中。然后在.htaccess里面我放了Silex让我放进去的东西:servers.html
发布于 2016-09-26 23:08:23
.htaccess需要位于web应用程序的根部,在web中也是如此。如果它不存在,就创建它。它应该包含这里所指示的内容,servers.html
AllowOverride All确实是需要的,但是如果您的web应用程序文件夹中没有任何.htaccess文件,那么它就有0的可能会工作。
https://stackoverflow.com/questions/39713633
复制相似问题