下述的这段转向设置的主要作用是使Apache从Http模式自动转向到Https模式。
而这段代码是作用于整个网站的转向
--------------------------------------------------------------------------------------
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
--------------------------------------------------------------------------------------
下面这段代码是用于某个目录的转向
--------------------------------------------------------------------------------------
RewriteEngine on
RewriteBase /folder
RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
--------------------------------------------------------------------------------------
转向规则主要配饰在httpd.conf中。
RewriteEngine on是重写引擎开关
443是端口号,443是https的端口。
---------------------------------------------------------
cd /usr/local/ssl/bin
openssl req -new -x509 -days 365 -nodes -out ssl.key -keyout ssl.key
cd /usr/local/httpd/conf/
mkdir ssl.crt
mkdir ssl.key
touch ssl.crt/server.crt
touch ssl.key/server.key
修改/usr/local/httpd/conf/ssl.conf
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]