.htaccess 协助精炼。htaccess

.htaccess 协助精炼。htaccess,.htaccess,.htaccess,我正在努力完善.htaccess文件中的代码,但在将子目录请求的url从https重写为http时遇到问题。以下是我的尝试: Options +FollowSymLinks RewriteEngine On RewriteCond %{SERVER_PORT} =443 RewriteCond %{REQUEST_URI} !\.(js|css|jpe?g|png|bmp|gif)$ [NC] RewriteRule !^dashboard(/.*)?$ http://%{SERVER_NAM

我正在努力完善
.htaccess
文件中的代码,但在将子目录请求的url从
https
重写为
http
时遇到问题。以下是我的尝试:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{SERVER_PORT} =443
RewriteCond %{REQUEST_URI} !\.(js|css|jpe?g|png|bmp|gif)$ [NC]
RewriteRule !^dashboard(/.*)?$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

RewriteCond %{SERVER_PORT} =80
RewriteRule ^dashboard(/.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
此代码适用于对根url的
https
请求,但当请求传入时,例如,url将被保留,并显示无效证书警告


我的意图是重写除
dashboard
子目录之外的所有请求。

尝试将dashboard子句置于rewrite状态:

RewriteCond %{SERVER_PORT} =443
RewriteCond %{REQUEST_URI} !\.(js|css|jpe?g|png|bmp|gif)$ [NC]
RewriteCond %{REQUEST_URI} !>dashboard [NC]
RewriteRule ^.*$ http://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

已尝试,但仍然没有重写为:(我很好奇将dashboard子句移动到RewriteCond的目的是什么?好的,您是否尝试使用%{HTTPS}=on而不是服务器端口?您使用哪个模块来服务器HTTPS连接,mod_ssl?%%{HTTPS}=on与%{server\u port}相同=443.我相当确定mod_ssl是用于服务https连接的模块。您是否也尝试过查看mod_rewrite调试输出?RewriteLogLevel 9,RewriteLog“/var/log/apache2/rewrite.log”?