apache httpd.conf 虚拟主机不工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/952706/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
httpd.conf virtual host not working
提问by Kezzer
I've added this:
我添加了这个:
<VirtualHost *:8888>
ServerName dietron
DocumentRoot /Users/kieransenior/Development/reformsoft_dietron/trunk/var/www/dietron/htdocs
<Directory /Users/kieransenior/Development/reformsoft_dietron/trunk/var/www/dietron/htdocs>
AllowOverride All
Options All
</Directory>
php_value include_path .:/Users/kieransenior/Development/reformsoft_dietron/trunk/var/www/dietron/include:/usr/local/lib/pear
php_value magic_quotes_gpc off
php_value register_globals off
</VirtualHost>
to my httpd.conf in the hope that my .htaccess file in the htdocs folder will be picked up with the following rules:
到我的 httpd.conf,希望我在 htdocs 文件夹中的 .htaccess 文件将按照以下规则被提取:
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/
That is the entire contents. I'm renaming .htaccess on my MBP by doing mv i.htaccess .htaccesswhich I'm assuming is correct? I'm using MAMP therefore the httpd.conf has a load of default settings and I added the first snippet above at the very end of it. I'm then restarting it by stopping Apache and starting it again. The index.php gets picked up fine, however when I do http://localhost:8888/anythinghereit comes up with a 404, which shouldn't happen.
这就是全部内容。我正在通过mv i.htaccess .htaccess我认为正确的方式重命名 MBP 上的 .htaccess ?我正在使用 MAMP,因此 httpd.conf 有大量默认设置,我在它的最后添加了上面的第一个片段。然后我通过停止 Apache 并重新启动它来重新启动它。index.php 得到了很好的处理,但是当我这样做时,http://localhost:8888/anythinghere它会出现 404,这不应该发生。
Any ideas on what I'm doing wrong?
关于我做错了什么的任何想法?
EDIT: Here's my httpd.conf
EDIT: Here's the error in the Apache log:
编辑:这是 Apache 日志中的错误:
[Fri Jun 05 16:02:22 2009] [error] [client ::1] File does not exist: /Users/kieransenior/Development/reformsoft_dietron/trunk/var/www/dietron/htdocs/testing
回答by chris
A couple of suggestions.
几个建议。
First, on line 461 of your httpd.conf:
首先,在 httpd.conf 的第 461 行:
AccessFileName afn.htaccess
Shouldn't that be .htaccess?
不应该是 .htaccess 吗?
The second thing I see is that the server name is set:
我看到的第二件事是设置了服务器名称:
ServerName dietron
but you're trying to access it with localhost
但你试图用本地主机访问它
I'd suggest that you put an entry in your /etc/hosts file so that dietron resolves, either to your local ip address or your loopback (127.0.0.1), and then access the server with http://dietron:8888
我建议您在 /etc/hosts 文件中添加一个条目,以便dietron 解析到您的本地 IP 地址或回送 (127.0.0.1),然后使用http://dietron:8888访问服务器
回答by Rob Wilkerson
Ensure that your AllowOverride directive is set properly at a global level. If no override is allowed (AllowOverride None) at your webroot, then your htaccess file will be ignored.
确保在全局级别正确设置 AllowOverride 指令。如果AllowOverride None您的 webroot不允许覆盖 ( ),那么您的 htaccess 文件将被忽略。

