我希望我的web服务器将所有http请求重定向到https。 所以我建立了我的.htaccess我的.htaccess重定向到https产生一个404
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
重定向似乎工作,但是当我进入_http://example.com/test/它重定向到_HTTPS://example.com/httpdocs/test/这会产生一个404错误。 如果我直接去_https://example.com/test/,一切正常!
重写模式中不需要前导斜杠。 –
你说得对,我把它删除了。 –