How to open a html file by default in my browser when i type the relevant url using apache?

StackOverflow https://stackoverflow.com/questions/22350892

  •  13-06-2023
  •  | 
  •  

Question

I know this may be long but please bear with me..

I am using Xubuntu. I have installed apache 2.something(I think it is 2.4) using sudo install from commandline. Inside my File System folder there is var folder inside of which there is www folder inside of which there is hello folder which contains a spring mvc application made by me named Fitness Tracker.

So basically the folder structure is (FileSystem/www/hello/FitnessTracker).The root folder is encrypted so all the folder had to be created at someplace at first and then through command line using sudo all were transferred to www/hello.Fitness Tracker has a html page inside it named hellothere.html.

Now when i start apache server from command line and then type following url in my browser localhost/hello/FitnessTracker . I get a directory structure of FitnessTracker meaning it shows the html file and the other subfolders FitnessTracker contains. Now my requirement is when localhost/hello/FitnessTracker is typed in address bar of browser, I have to open hellothere.html page. How can this be done??

P.S. I have already placed a virtual host file inside my sites-available directory which contains the following code

 <VirtualHost *:80>
 ServerName east.example.org
 DocumentRoot /var/www/hello/FitnessTracker
<Directory /var/www/hello/FitnessTracker>
Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
</Directory>
</VirtualHost>

Here for my code localhost/hello/FitnessTracker and http://east.example.org/ calls are synonomous which means both of them return the directory structure.

Was it helpful?

Solution

Add DirectoryIndex hellothere.html to your vhost config.

Also placing in sites-available won't be enough for you to use the vhost, it needs to be sym-linked in sites-enabled, or run sudo a2ensite mysite and sudo /etc/init.d/apache2 restart

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top