Apache-2.2

“com/index.php”在apache中沒有斜線

  • December 1, 2019

最後我已經完成安裝 SSL 證書並完成配置從舊站點到新站點的重定向,但是現在當我嘗試從舊站點進入時,它會發送給我到新站點但沒有“/”,例如:

https://newsite.comindex.php?blabla

這是我的 httpd.conf 配置:

<VirtualHost oldsite.com:80>
       ServerName oldsite.com
       Redirect permanent "/" https://newsite.com/
</VirtualHost>
<VirtualHost oldsite:443>
       ServerName oldsite.com
       Redirect permanent "/" https://newsite.com/
</VirtualHost>
<VirtualHost *:80>
       ServerName https://newsite.com
       Redirect permanent "/" https://newsite.com/
</VirtualHost>

我非常感謝您能提供的任何幫助。

試試這樣:

<VirtualHost *:80>
       ServerName oldsite.com
       Redirect permanent / https://newsite.com/
</VirtualHost>
<VirtualHost *:443>
       ServerName oldsite.com
       Redirect permanent / https://newsite.com/
       SSLEngine On
       SSLCertificateFile oldcert…
       SSLCertificateKeyFile oldkey…
</VirtualHost>
<VirtualHost *:443>
       ServerName https://newsite.com
       Redirect permanent / https://newsite.com/
       SSLEngine On
       SSLCertificateFile newcert…
       SSLCertificateKeyFile newkey…

       <Directory /var/www/html/mysite/>

       </Directory>
</VirtualHost>

NameVirtualHosts 不應再使用。請注意您的目錄指令中有一個斜杠。

引用自:https://serverfault.com/questions/942681