IP address show Apache welcome page but domain name working!

Issues related to configuring your network
Post Reply
hack3rcon
Posts: 697
Joined: 2014/11/24 11:04:37

IP address show Apache welcome page but domain name working!

Post by hack3rcon » 2020/09/21 13:06:15

Hello,
When I visit my website by its IP address the welcome page of Apache showed, but with "https://domain-name.net" everything is OK. How can I block direct access by IP or forward it to domain?
I enabled "mod_rewrite" and my Virtual Host config is:

Code: Select all

RewriteEngine on
RewriteCond %{SERVER_NAME} =mydomain.com [OR]
RewriteCond %{SERVER_NAME} =www.mydomain.com
RewriteCond %{HTTP_HOST} ^"Server IP Address"
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
But problem not solved.

Thank you.

hack3rcon
Posts: 697
Joined: 2014/11/24 11:04:37

Re: IP address show Apache welcome page but domain name working!

Post by hack3rcon » 2020/09/22 18:38:25

Where is the "000-default.conf" file?

BShT
Posts: 329
Joined: 2019/10/09 12:31:40

Re: IP address show Apache welcome page but domain name working!

Post by BShT » 2020/09/22 19:49:58

create a vhost and set ServerName to your IP then redirect it to your www

000-default is a debianware conf

hack3rcon
Posts: 697
Joined: 2014/11/24 11:04:37

Re: IP address show Apache welcome page but domain name working!

Post by hack3rcon » 2020/09/22 20:22:45

Here is my Virtual Host:

Code: Select all

<VirtualHost *:80>
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
ServerAdmin root@localhost
ServerName www.example.net
ServerAlias www.example.net
DocumentRoot /var/www/wordpress
<Directory "/var/www/wordpress">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted
</Directory>
ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log common
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.net [OR]
RewriteCond %{SERVER_NAME} =www.example.net 
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
Redirect permanent / https://www.example.net
</VirtualHost>
Can you show me your purpose on it?

hack3rcon
Posts: 697
Joined: 2014/11/24 11:04:37

Re: IP address show Apache welcome page but domain name working!

Post by hack3rcon » 2020/09/24 15:01:53

I did:

Code: Select all

RewriteCond %{SERVER_NAME} 1.2.3.4
RewriteRule /(.*) https://example.net/$1 [R=301,L]
But problem not solved :(

Post Reply

Return to “CentOS 8 - Networking Support”