我想从重定向htt_p所有连接://www.example.com/abc.html到HTTP_S://www.example.com/abc.html。将工作对此有何mod_alias中或mod_rewrite的命令?我已经试过:

RewriteEngine on
RewriteCond %{HTTPS} =off
RewriteRule $abc\.html^ https://www.example.com/abc.html [R]

在两者的.htaccess和httpd.conf中但不工作。它的工作原理,如果在重写规则的第一个字符串是别的(如abz.html),但如果它不是abc.html。 abc.html是服务器(不是另一个重定向)上一个真正的文件。有FollowSymLinks存在于适当的目录的指令。

非常感谢。

有帮助吗?

解决方案

沿着以下的东西线将允许您重定向非SSL页到SSL版本(假设你是在端口443上运行SSL):

RewriteEngine on

# Limited redirects
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{REQUEST_URI} ^/abc\.html$ [OR,NC]
RewriteCond %{REQUEST_URI} ^/def\.html$ [OR,NC]
RewriteCond %{REQUEST_URI} ^/ghi\.html$ [NC]
RewriteRule ^/(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

的RewriteCond后的[OR]标志为字面上的是,“或”,这就是为什么在最后一个条件没有它

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top