我有以下.htaccess文件:
RewriteEngine on RewriteBase / RewriteRule ^(/?)dir/?$ $1dir/subdir [L] RewriteRule ^(/?)subdir2/?$ $1dir/subdir/subdir2 [L]
redirect工作正常,如果我键入域的IP,但在域名/目录input根本不redirect我,而是显示目录的内容。
另一个问题:正如我所说的,redirectIP工作正常。 不过,虽然没有设置“R”标志,但是url地址会改变。 IP / dir变成IP / dir / subdir。 为什么?
编辑(11:20 GMT + 1):不太确定是否有任何相关性,但在今天之前,服务器没有一个域。 我刚刚买了一个域名,并设置了所有指向服务器的名称服务器。 由于我可以访问该页面,它显示了/ dir文件夹的内容,我假设我没有搞砸任何东西。
编辑(12:51 GMT + 1):输出从apachectl -S:
apache2: Could not reliably determine the server's fully qualified domain name, using 0.0.10.188 for ServerName VirtualHost configuration: wildcard NameVirtualHosts and _default_ servers: *:80 is a NameVirtualHost default server 0.0.10.188 (/etc/apache2/sites-enabled/000-default:1) port 80 namevhost 0.0.10.188 (/etc/apache2/sites-enabled/000-default:1) Syntax OK
编辑(19:26 GMT + 1):发现问题。 问题是我的服务器名称没有设置,我在ports.conf和httpd.conf中都有重复,都在“聆听”。 感谢您指出“apachectl -S”命令。 遗留一个神秘的问题:虽然没有设置R标志,但为什么URL会更改。 永远是一个谜…
你需要显示更多信息; 什么是httpd -S输出?
这些规则放在哪里?