【问题标题】:Strange behaviour between wamp and lamp (ubuntu)wamp和lamp之间的奇怪行为(ubuntu)
【发布时间】: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


【解决方案1】:

你确定apache.conf文件和站点配置文件是一样的吗?

从外观上看,一个DirectoryIndexindex.php,而另一个indexDirectoryIndex时间>。有关 DirectoryIndex 的更多信息,请参阅http://httpd.apache.org/docs/2.2/mod/mod_dir.html

【讨论】:

  • 我认为 OP 意味着他在两个系统上都打开了重写模块。
  • 即使他有一个重写,他没有在这里发布所以我不能确定,一个显示索引请求,而另一个显示 index.php。这并不能解释是重定向导致了这个还是服务器是。
  • 重写在两个系统上都已关闭。请以粗体查看我的文字!
  • @nrathaus:所有目录都没有 .htaccess
  • apache.conf 怎么样?或sites-enabled/*.conf ?
【解决方案2】:

这是因为 Apache Conf 中的这个选项:

Options FollowSymLinks

【讨论】:

  • 确保您还通过从 Ubuntu 中删除它进行测试,看看它是否仍然有效。某些功能在 Windows 上可能具有不同的行为。
  • 你真是个天才!!!将此添加到 wamp 上的 apache conf 工作 Options Indexes FollowSymLinks MultiViews。所以现在当我输入localhost/index 时,它会解析为默认索引页面!!这就是我们在 LAMP (ubuntu) 中所拥有的!!多年来一直试图解决这个问题!!!
  • 几年前我偶然发现了它。它实际上给我带来了麻烦,需要禁用它。在阅读了 Apache 文档后,我找到了它。
  • 有人可能认为它的 url 重写,它不是!可能对此进行问答会有所帮助!
  • 这意味着:关注类似的链接。这意味着如果它找不到链接,它将显示最相似的链接。在您的情况下 index.php 或其他任何内容,而不仅仅是索引。就我而言,它在请求未找到的 26.jpg 时显示 27.jpg。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多