apache - 将站点更改为 ssl 安全后解析页面时从 URL 中删除斜杠

标签 apache ssl

我最近使我的一个网站 ssl 安全。从那时起,我注意到如果我将网站上其中一个页面的 url 粘贴到浏览器 url 栏中,当该页面尝试解析时,该 url 会被破坏并且找不到该页面。它似乎总是做的是删除域和以下目录后面的斜杠,所以

waynecbent.com/html/somefile.html

变成:

waynecbent.comhtml/somefile.html

起初我以为这是我的浏览器正在做的事情,但后来我发现这种情况发生在不同平台的不同浏览器上。

我联系了我的域名提供商 (Namecheap),但他们说这是主机的问题。

我的站点配置如下:

<VirtualHost *:443>
  ServerName www.waynecbent.com
  DocumentRoot /home/<redacted>/public_html
  SSLEngine on
  SSLCertificateFile "/home/<redacted>/ssl/<redacted>.crt"
  SSLCertificateKeyFile "/home/<redacted>/ssl/<redacted>.pem"
  SSLCACertificateFile "/home/<redacted>/ssl/<redacted>_bundle"
</VirtualHost>
<VirtualHost *:443>
  ServerName waynecbent.com
  DocumentRoot /home/<redacted>/public_html
  SSLEngine on
  SSLCertificateFile "/home/<redacted>/ssl/<redacted>.crt"
  SSLCertificateKeyFile "/home/<redacted>/ssl/<redacted>.pem"
  SSLCACertificateFile "/home/<redacted>/ssl/<redacted>_bundle"
</VirtualHost>

有人知道这是为什么吗?

谢谢,阿拉索

最佳答案

与 Lizardx 的解决方案密切相关,我有一个未正确编写的 Redirect 指令:

<VirtualHost *:80>
  ServerName waynecbent.com
  Redirect "/" "https://waynecbent.com"
</VirtualHost>

我需要在域后添加尾部斜杠:

Redirect "/" "https://waynecbent.com/"

我将接受 Lizardx 提供的信息丰富的答案,因为它是催化剂并认识到发生了重定向。

编辑:

引用下面 Lizardx 的评论,您似乎可以使用 Redirect 指令通过以下方式进行永久重定向:

Redirect 301 "/" "https://example.com/"
Redirect permanent "/" "https://example.com/"

我还注意到,我阅读过一些关于使用 Redirect 指令将非 ssl url 重定向到 ssl 的在线文档给出了不包含尾部斜杠的示例。但是,正如该线程所揭示的那样,这在我的案例中造成了问题。

关于apache - 将站点更改为 ssl 安全后解析页面时从 URL 中删除斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39001868/

相关文章:

linux - CentOS 7 Apache HTTPD Kerberos Windows AD 问题

java - 在 Karaf 中使用 ssl 连接到数据源,得到 java.lang.NoClassDefFoundError : javax/net/ssl/TrustManager

php - mysql_connect() 在本地主机上工作正常,但在访问单独的 ip 时却不行

java - 移动 SSL 证书 - 现在获取 java.security.cer.CertPathValidatorException

.htaccess - 在整个站点范围内删除 www,在某些目录上强制使用 https,在其余目录上强制使用 http?

apache - 内部错误 500 Apache,但日志中没有任何内容?

java - Apache PDFBox : Move the last page to first Page

apache - 通过 404 而不是 403 拒绝

ssl - Spring Security,ssl ldap,没有证书

apache - Solr不会配置