由于虚拟主机的重定向,现在无法访问 phpmyadmin

Access to phpmyadmin is not possible now due to redirection of virtualhosts

我有一个有两个子域的服务器,所以我专门为我的两个子域设置了重定向,因为我想强制这两个子域只能通过 https 而不是 http 访问。我的理想情况是我没有改变这些重定向并且能够在本地访问 phpMyAdmin(显然出于安全原因)但现在的问题是当我在浏览器中键入以下内容时: 127.0.0.1/phpmyadmin 或 localhost/phpmyadmin 它带我到 https://example1.com/webservice/myrestfile-REST.php?appconfig=example

有什么办法可以解决这个问题吗?

这是我目前的重定向配置:

 <VirtualHost *:80>

 ServerName example1.com
 ServerAlias API.com
 ErrorLog /var/www/html/error.log
 CustomLog /var/www/html/requests.log combined
 DocumentRoot /var/www/html

 RewriteEngine On

 LogLevel alert rewrite:trace6
 RewriteCond %{HTTPS} !=on
# This checks to make sure the connection is not already HTTPS

RewriteRule ^ https://example1.com/webservice/myrestfile-REST.php?appconfig=example [R,L]


Redirect permanent / https://example1.com

#   RewriteRule ^(.*)$ /webservice/myrestfile-REST.php?appconfig=example [QSA,L]


</VirtualHost>

<VirtualHost *:443>
ServerName example1.com
DocumentRoot /var/www/html

 RewriteEngine On
RewriteRule ^(.*)$ /webservice/myrestfile-REST.php?appconfig=example [QSA,L] 
SSLEngine On
SSLCertificateFile /etc/httpd/ssl/40d5d69ae6a53.crt
SSLCertificateKeyFile /etc/httpd/ssl/sitekey.key
SSLCertificateChainFile /etc/httpd/ssl/gd_bundle-g2-g1.crt

</VirtualHost> 

看起来您已将 apache 设置为侦听任何 ip <VirtualHost *:80>,其中将包含环回地址 127.0.0.1。看看你是否可以只使用条件来忽略这些。

RewriteEngine On
RewriteCond %{REQUEST_URI} !^/phpmyadmin$ [NC]
RewriteCond %{HTTP_HOST} !^127\.0\.0\.1 [OR]
RewriteCond %{HTTP_HOST} !^localhost [NC]
RewriteRule ^(.*)$ /webservice/myrestfile-REST.php?appconfig=example [QSA,L]

看看它是如何工作的,然后告诉我。