Redirect ip address to https server name

Alles, was den Apache betrifft, kann hier besprochen werden.

Redirect ip address to https server name

Postby JohnDoern » 18. October 2021 12:39

So this is my conf:

Code: Select all
<VirtualHost *:80>
  <Directory /var/www/html/webserver/public>
      Allow From All
      AllowOverride All
      Options -Indexes
  </Directory>

  DocumentRoot /var/www/html/webserver/public
  ServerName ./install.sh
</VirtualHost>
<VirtualHost *:80>
  <Directory /var/www/html/webserver/public>
      Allow From All
      AllowOverride All
      Options -Indexes
  </Directory>

  DocumentRoot /var/www/html/webserver/public
  ServerName www.test.com
  ServerAlias www.test.com
  Redirect permanent / https://test.com/

RewriteEngine on
#RewriteBase /
RewriteCond %{SERVER_NAME} =www.test.com [OR]
RewriteCond %{SERVER_NAME} =test.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>


This works perfectly for http -> https redirection. For example test.com or http://test.com redirects to https://test.com. www.test.com does not work (i don't know why?), i'll get a 404 page. Next big thing, lets assume the ip of my webserver is 12.23.45.67 - how do i have to change my config file, so this ip also redirects to https://test.com?
JohnDoern
 
Posts: 1
Joined: 18. October 2021 12:34
XAMPP version: 7.4.13
Operating System: Debian

Return to Apache

Who is online

Users browsing this forum: No registered users and 28 guests