繁体   English   中英

Apache2-目录URL,不带斜杠重定向到其他URL

[英]Apache2 - Directory URL without trailing slash redirecting to different URL

我在使用Apache2的子目录中自动加载index.php时遇到问题。 这是我在连接时在浏览器控制台中看到的内容:

GET http://example.com/login                     HTTP 301 Moved Permanently
GET http://10.0.3.10/login/
Connection Timed Out

当我输入http://example.com/login/时 ,它将按预期工作。 另外,根目录正确地重定向到index.php。

我对这个话题还很陌生,希望能对您有所帮助。

默认虚拟主机设置:

#NameVirtualHost *:80
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName example.com/
        ServerAlias www.example.com/

        DocumentRoot /var/www/example.com/
        <Directory />
                AllowOverride All
                DirectoryIndex index.php
        </Directory>
        <Directory /var/www/example.com/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>
...

httpd.conf中:

<IfModule dir_module>
DirectoryIndex index.php
</IfModule>

没有使用.htaccess文件。

我认为您的请求是由没有ServerName的虚拟主机处理的,在启动时httpd可能警告您,它找不到本地IP的默认主机名(10.0.3.10)

尝试从ServerName和ServerAlias中删除斜杠。 如果您的ServerName或ServerAlias与系统主机名匹配,您将需要做更多的工作,即在默认的vhost中添加一个虚拟的ServerName。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM