HTTP重定向不重定向
HTTP redirect not redirecting
按照建议here,我在 Apache 配置文件中使用了以下代码(本例中为默认-ssl.conf)
<VirtualHost *:80>
ServerName name.domain.com
Redirect / https://name.domain.com/
</VirtualHost>
我重新启动了 Apache 并且...没有任何反应。没有错误,没有重定向。 http作为http,https作为https。我做错了什么?我的域名不是以 "www" 开头,但我无法想象这会有什么不同。
不确定这是否有帮助,有时浏览器会尝试清除 DNS 缓存,在 chrome 中,您可以转到 chrome://net-internals/#dns 并清除它,或使用其他浏览器测试。
<VirtualHost *:80>
DocumentRoot /home/webroot/example.com/htdocs
ServerName example.com
ServerAlias www.example.com
<Directory /home/webroot/example.com/htdocs>
FileETag MTime Size
DirectoryIndex index.php index.html index.htm
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
Redirect permanent / http://www.example.com/
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog /home/webroot/example.com/logs/error_log
CustomLog /home/webroot/example.com/logs/access_log combined
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/webroot/example.com/htdocs
ServerName www.example.com
RewriteEngine on
Redirect permanent / http://www.example.com/
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog /home/webroot/example.com/logs/error_log
CustomLog /home/webroot/example.com/logs/access_log combined
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
按照建议here,我在 Apache 配置文件中使用了以下代码(本例中为默认-ssl.conf)
<VirtualHost *:80>
ServerName name.domain.com
Redirect / https://name.domain.com/
</VirtualHost>
我重新启动了 Apache 并且...没有任何反应。没有错误,没有重定向。 http作为http,https作为https。我做错了什么?我的域名不是以 "www" 开头,但我无法想象这会有什么不同。
不确定这是否有帮助,有时浏览器会尝试清除 DNS 缓存,在 chrome 中,您可以转到 chrome://net-internals/#dns 并清除它,或使用其他浏览器测试。
<VirtualHost *:80>
DocumentRoot /home/webroot/example.com/htdocs
ServerName example.com
ServerAlias www.example.com
<Directory /home/webroot/example.com/htdocs>
FileETag MTime Size
DirectoryIndex index.php index.html index.htm
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
Redirect permanent / http://www.example.com/
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog /home/webroot/example.com/logs/error_log
CustomLog /home/webroot/example.com/logs/access_log combined
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /home/webroot/example.com/htdocs
ServerName www.example.com
RewriteEngine on
Redirect permanent / http://www.example.com/
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
ErrorLog /home/webroot/example.com/logs/error_log
CustomLog /home/webroot/example.com/logs/access_log combined
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>