【发布时间】:2021-09-25 04:42:29
【问题描述】:
这是我尝试在 httpd.conf 中应用的代码:
<VirtualHost *:80>
ServerName www.test.com
ServerAlias www.test.com
DocumentRoot /home/test_com
ErrorLog /home/logs/apache/www_test/www.test.com-error_log
CustomLog /home/logs/apache/www_test/www.test.com.-access_log common env=!do_not_log
# https redirect
RewriteEngine On
RewriteCond %{HTTP_HOST} www.test.com
RewriteCond %{REQUEST_URI} /example
RewriteRule . https://www.test.com/example.html [R=303,L]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}
<Directory "/home/test_com/">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
应用代码并重新启动 apache 后,当我转到 /example 时,我得到一个 404 not found 响应。
当我在 (https://htaccess.madewithlove.be) 测试 htaccess 时,输出是我想要的 https://www.test.com/example.html。我想知道问题是什么。
【问题讨论】:
-
您是通过 HTTP 还是 HTTPS 发出请求?您的所有指令都在
<VirtualHost *:80>容器中,并且您正在重定向到 HTTPS?