How do I make virtual host DirectoryIndex file appear in the url?
I have setup a virtual host which specifies a default file to load when the URL is called.
The problem I have is that I need that default DirectoryIndex file to appear in the URL.
So when I go to: www.mysite.co.uk, I want www.mysite.co.uk/app.php to appear in the URL.
How can I achieve this using my virtual host configuration within my apache.conf file?
Here is my current code:
<VirtualHost *:80>
ServerName *.mysite.co.uk
DocumentRoot "/var/www/html/mysite/web/"
DirectoryIndex app.php
</VirtualHost>
Solution 1:
I am not sure if you are able to force the browser to show the default page, as that sort of defeats it's purpose. The best idea I could think of would be to leave the default as index.html, and use mod_rewrite to direct index.html to app.php.
This should work for the default index (http://domain.com/) and show desired url in browser (http://domain.com/app.php)
<VirtualHost *:80>
ServerName *.mysite.co.uk
DocumentRoot "/var/www/html/mysite/web/"
DirectoryIndex index.html
RewriteEngine on
RewriteRule ^index\.html$ app.php$1 [L,R=301]
</VirtualHost>