Apache2 only loads indexof or 404 when i try to open a other

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

Apache2 only loads indexof or 404 when i try to open a other

Postby Thejojo » 07. June 2024 21:36

i am trying to set my webpage in apache2. When i try to open a .html file throu the browser line (example: https://example.com/index.html) it only shows the standart 404 Page of Apache2

my site config: /etc/apache2/sites-aviable/000-default.conf

ServerName example.com
ServerAdmin it@example.com
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined <IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost> ```

And the Structure of the /var/www/html Folder:
html
|favicon.ico
|index.html
|othersite.html
|background.png
|style.css
And if i try to oopen the index.html directly the error 404 also comes. It should open the correct .html file but it only shows the 404 Page :"Not Found The requested URL was not found on this server. Apache/2.4.55 (Ubuntu) Server at example.com Port 443" Thanks for help
Thejojo
 
Posts: 1
Joined: 07. June 2024 21:33
XAMPP version: Apache on server
Operating System: Arch, Ubuntu, Windows

Re: Apache2 only loads indexof or 404 when i try to open a o

Postby Nobbie » 08. June 2024 12:12

Did you add example.com to your local hosts file? Or have you a DNS Server running which resolves example.com to your server? If not, example.com resolves to a server in the internet.

Normally you cannot use any other domain than localhost.

The above configuration is incomplete as well (missing <Virtualhost ...> directive) and the RewriteRule looks wrong. Instead of a Rewrite a simple Redirect will work better.
Nobbie
 
Posts: 13271
Joined: 09. March 2008 13:04


Return to Apache

Who is online

Users browsing this forum: No registered users and 5 guests