I have Apache httpd server running in my Linux box with SSL enabled using LetsEncrypt. The root directory of html files is /var/www/html
. Let me show the structure of /var/www/html
below;
-html
|_ index.php
|_ file1.php
|_ dir1
| |_ index.php
|_ dir2
|_ index.php
I am able to access the website using https://example.com
url. What I am trying to achieve is if the user try to access https://example.com/dir3
(which is not present), the index.php
file of root directory should be delivered. Or, if the user try to access https://example.com/dir3/file1.php
, the file file1.php
of root should be delivered.
I tried editing virtual host in /etc/httpd/conf.d/vhost-le-ssl.conf
but is showing file not found. Let me describe vhost-le-ssl.conf
below;
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/html
ServerAdmin info@example.com
Alias /dir3 "/var/www/html"
<Directory /var/www/html>
AllowOverride None
</Directory>
RewriteEngine on
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/$
RewriteRule dir3/* /var/www/html [R=301]
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
</VirtualHost>
</IfModule>
How can I fix this?