【发布时间】:2013-12-13 22:38:22
【问题描述】:
自从我搬到 Linux 以来,我注意到一些奇怪的行为。在 Ubuntu 中,http://localhost/index 有效,但在 WAMP 上无效。 我在 APACHE 的重写模块都设置为关闭的情况下对此进行了测试。有什么好的解释吗?
Apache.conf (LAMP)
etc/apache2/sites-enabled/000-default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Apache.conf WAMP
<Directory "C:/wamp/www/">
#
# 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/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# 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 all
#
# Controls who can get stuff from this server.
#
# onlineoffline tag - don't remove
Order Allow,Deny
Allow from all
</Directory>
编辑:多亏了 [tntu][2]
由于 LAMP (ubuntu) 上的 Options Indexes FollowSymLinks MultiViews 指令,url localhost/index 可以解析为文件 index.php、index.html。所以 foo 也会导致 foo.php、foo.html。正确的解释可以来源于http://httpd.apache.org/docs/current/content-negotiation.html
不要误以为这是 url 重写
【问题讨论】:
-
请提供您的 mod_rewrite 声明
-
mod_rewrite 都关闭了!
-
所以,如果 mod_rewrite 关闭,请参阅我的回答,我相信区别在于
DirectoryIndex值,或者在其中一个设置中缺少它 -
conf.d/有什么?和sites-enabled/?某处必须有一个 DirectoryIndex -
转到
/etc/apache2,然后:grep -r DirectoryIndex *看看它会返回什么
标签: php url-rewriting apache2 wamp lamp