redirect别名,但不是IP

我有一个虚拟私人服务器下debian 7。

在这个服务器上,我有一个可以访问的网站,比方说https://www.monsiteweb.fr

我的IP地址是212.227.100.200 ,我可以通过212.227.100.200/phpmyadmin访问phpMyAdmin

我想将monsiteweb.fr * .monsiteweb.fr的用户redirect到https://www.monsiteweb.fr 。

问题是,当我做这个redirect,我不能再访问212.227.100.200/phpmyadmin自动重写为htps://www.monsiteweb.fr/phpmyadmin (我写htps而不是https,因为我不能在post上添加2个以上的链接)

我怎么能这样做,monsiteweb.fr * .monsiteweb.frredirect到htps ://www.monsiteweb.fr212.227.100.200不redirect?

/ etc / apache2 /网站启用/我有3个文件,我可能搞砸了经验不足:

文件1:000-默认

<VirtualHost *:80> ServerAdmin [email protected] ServerName monsiteweb.fr ServerAlias monsiteweb.fr *.monsiteweb.fr Redirect permanent / https://www.monsiteweb.fr DocumentRoot /var/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> 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 LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

文件2:monsiteweb.fr

  NameVirtualHost *:443 <VirtualHost *:80> ServerAdmin [email protected] ServerName monsiteweb.fr ServerAlias monsiteweb.fr *.monsiteweb.fr </VirtualHost> <VirtualHost *:443> ServerAdmin [email protected] ServerName monsiteweb.fr ServerAlias monsiteweb.fr *.monsiteweb.fr SSLEngine On SSLCertificateKeyFile /etc/apache2/ssl.certs/geotrust_privatekey_2016.key SSLCertificateFile /etc/apache2/ssl.certs/geotrust_publickey_2016.crt SSLCertificateChainFile /etc/apache2/ssl.certs/geotrust_intermediateca_2016.crt DocumentRoot /home/monsiteweb/www/ <Directory /home/monsiteweb/www/> Options -Indexes AllowOverride All </Directory> </VirtualHost> 

文件3:default-ssl

  <VirtualHost *:80> ServerAdmin [email protected] ServerName monsiteweb.fr ServerAlias monsiteweb.fr *.monsiteweb.fr DocumentRoot /home/monsiteweb/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/> 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 LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> 

首先,您应该能够使用http://127.0.0.1/phpMyAdmin或本地IP http://192.168.0.100/phpMyAdmin (例如)访问phpMyAdmin。

现在,如果您想使用公共IP访问phpMyAdmin,则必须考虑可能的安全问题。 您至less可以限制对某些IP的访问权限并放置其他授权。

你正在运行的VirtualHosts。 这是一个基于名称的系统。 如果发出请求,系统将查找与请求相匹配的VirtualHost,并且将基于ServerName和ServerAlias。 如果找不到名称,系统将自动响应DEFAULT VIRTUAL HOST – 000-default.conf和default-ssl.conf。

通过http:// Your_Public_IP / phpMyAdmin ,将从指定的主机中searchYour_Public_IP,显然它不会在那里find它。 所以它会响应默认虚拟主机(你已经configuration为服务https://monsiteweb.fr )。

你提到任何指向monsiteweb.fr的人都应该被redirect到https://www.monsiteweb.fr 。 所以我假设你不希望使用http:// Your_Public_IP的人也会被redirect到那里。

你可以configuration一个简单的redirect:

 <VirtualHost *:80> ServerName *.monsiteweb.fr Redirect 301 / https://www.monsiteweb.fr </VirtualHost> 

这将redirect除http:// Your_Public_IP的stream量之外的所有stream量。 如果你使用它来访问phpMyAdmin,它应该已经工作。