我已经设置了一个虚拟主机,它指定了一个默认的文件加载URL时调用。
我遇到的问题是我需要默认的DirectoryIndex文件出现在URL中。
所以当我去www.mysite.co.uk时,我想让www.mysite.co.uk/app.php出现在URL中。
我如何使用我的apache.conf文件中的虚拟主机configuration来实现这个function?
这是我现在的代码:
<VirtualHost *:80> ServerName *.mysite.co.uk DocumentRoot "/var/www/html/mysite/web/" DirectoryIndex app.php </VirtualHost>
我不确定您是否能够强制浏览器显示默认页面,因为这样做会影响它的目的。 我能想到的最好的办法是将默认值保留为index.html,并使用mod_rewrite将index.html指向app.php。
这应该为默认索引( http://domain.com/ ),并显示在浏览器( http://domain.com/app.php )所需的url
<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>