【发布时间】:2015-04-28 13:27:22
【问题描述】:
我的网站在 https 中时,我的网站中的所有链接都损坏了。无论如何,我需要做的是将所有请求从http 重定向到https,所以我在.htaccess 中添加了以下代码。
# Redirect from http to https.
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^project-local\.com*
RewriteRule ^(.*)$ https://project-local.com/$1 [L,R=301]
重定向工作正常,但是如果我在 https 中单击站点中的任何链接会发生什么,所有响应都是 404。
这是我的 ssl vhost 的样子:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerName project-local.com
DocumentRoot /home/snake/repo/project-a/docroot
ErrorLog ${APACHE_LOG_DIR}/project-a-ssl_error.log
CustomLog ${APACHE_LOG_DIR}/project-a-ssl_access.log common
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
<Directory /home/snake/repo/project-a/docroot/>
Require all granted
</Directory>
BrowserMatch "MSIE [2-6]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
# MSIE 7 and newer should be able to use keepalive
BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown
</VirtualHost>
</IfModule>
【问题讨论】:
标签: apache .htaccess http-status-code-404