Apache 根 URL 重定向到双斜杠

Apache 根 URL 重定向到双斜杠

我有一个需要重定向/到的虚拟主机/app,并且我使用以下命令在 vhost.conf 中完成该操作:

RewriteEngine On
RewriteRule ^/$ /app [R]

但这让我很难受,因为用户http://server.com//应用程序地址。

如何修复?

答案1

suku@ubuntu-vm:/var/www/local$ grep Redirect /etc/apache2/sites-available/default
        RedirectMatch ^/$ /app

suku@ubuntu-vm:/var/www/local$ curl http://127.0.0.1/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://127.0.0.1/app">here</a>.</p>
<hr>
<address>Apache/2.2.22 (Ubuntu) Server at 127.0.0.1 Port 80</address>
</body></html>

答案2

似乎重定向之后,应用程序本身会将页面重定向到/login

因此,为了避免双重重定向,只需将根重定向/到正确的页面,然后将其添加到 apache 配置中/etc/apache/sites-available/vhost.conf

RewriteEngine On
RewriteRule ^/$ /app/login.axvw [R]

相关内容