HTTP重定向不重定向
问题描述:
至于建议here,我使用下面的代码Apache的配置文件(在这种情况下,默认的ssl.conf)HTTP重定向不重定向
<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>
这也没有效果(正面或负面)。绝对不是DNS缓存问题。似乎和 VirtualHost>之间的所有内容都被忽略了...... –
Stumbler
我编辑了我的答案看看是否有帮助,也不要忘记重新启动httpd –
感谢您的帮助。我意识到问题所在。 default-ssl.conf仅用于使用ssl进行配置,并且在该阶段告诉它有关http的任何信息已为时太晚。你描述的代码,如果放在000-default.conf(ubuntu服务器14.4)中,可以。 – Stumbler