httpd.conf虚拟主机无法正常工作

时间:2021-08-13 02:44:15

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:

希望htdocs文件夹中的.htaccess文件可以使用以下规则获取到我的httpd.conf:

RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1

That is the entire contents. I'm renaming .htaccess on my MBP by doing mv i.htaccess .htaccess which 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/anythinghere it comes up with a 404, which shouldn't happen.

这是整个内容。我正在通过mv i.htaccess .htaccess重命名我的MBP上的.htaccess我认为这是正确的吗?我正在使用MAMP因此httpd.conf有一堆默认设置,我在它的最后添加了上面的第一个片段。然后我通过停止Apache并重新启动它来重新启动它。 index.php很好,但是当我执行http:// localhost:8888 /任何地方时,它会出现404,这不应该发生。

Any ideas on what I'm doing wrong?

关于我做错的任何想法?

EDIT: Here's my httpd.conf

编辑:这是我的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

2 个解决方案

#1


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

但是你试图用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访问服务器

#2


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指令。如果您的webroot没有允许覆盖(AllowOverride None),那么您的htaccess文件将被忽略。

#1


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

但是你试图用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访问服务器

#2


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指令。如果您的webroot没有允许覆盖(AllowOverride None),那么您的htaccess文件将被忽略。