我正在使用Apache mod rewrie将httpredirect到https,但现在无法连接到localhost / phpmyadmin

这里是我的/ etc / apache2 / sites-enabled / 000-default

<VirtualHost *:80> ServerAdmin [email protected] RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://mysite.com DocumentRoot /var/www/http <Directory /> Options None AllowOverride None </Directory> <Directory /var/www/http> Options -Indexes -FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> 

不知道如何解决这个问题。 有什么想法吗?

你应该可以连接到“ https:// localhost / phpmyadmin ”。

或者,您可以修改您的RewriteRule以包含匹配string的反向引用。

 RewriteRule /(.*) https://mysite.com/$1 [R=301] 

我会使用下面的RewriteRules来完成redirect。 这将保留请求的URL,只需将协议更改为https://

 RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^/(.*) https://%{SERVER_NAME}%{REQUEST_URI} [R]