Apache的vhost中配置默认访问入口index-test.php的方法(Yii)

  •   
  • 6839
  • Linux
  • 9
  • super_dodo
  • 2016/08/04

最近的参与的Yii项目有多个分支,所以在入口文件里面有区分(index.php index-test.php index-beta.php)等。不同的入口文件对应不同的环境和配置。

这个时候在本地建立测试环境的时候希望是index-test的入口。因为本地又有多项目,所以使用到apache的vhost。直接上配置,请注意index-test.php在两个地方出现哦。

<VirtualHost *:80>
    DocumentRoot "D:\wamp\www\dodo\v4.dodobook.net"
    ServerName   my-v4.dodobook.net
	ServerAlias  my-v4.dodobook.net
	ErrorLog "logs/v4.dodobook.net-error.log"
	CustomLog "logs/v4.dodobook.net-access.log" common
    <Directory "D:\wamp\www\dodo\v4.dodobook.net">
		DirectoryIndex index-test.php index.php
		Options +Indexes +FollowSymLinks +MultiViews
		AllowOverride None
		Order allow,deny
		Allow from all
    </Directory>
	RewriteEngine On
	RewriteRule ^(/web|/assets|/css|/js|/images|/ueditor|/upload|/favicon\.ico).* $0 [L]
	RewriteCond %{QUERY_STRING} ^(.*)$
	RewriteRule ^([^\?]*)$  /index-test.php$1?%1 [L]
</VirtualHost>

顺带贴上默认是index.php的入口文件的简化版的vhost配置

<VirtualHost *:80>
    DocumentRoot "D:\wamp\www\dodo\v4.dodobook.net"
    ServerName   my-v4.dodobook.net
	ServerAlias  my-v4.dodobook.net
	ErrorLog "logs/v4.dodobook.net-error.log"
	CustomLog "logs/v4.dodobook.net-access.log" common
    <Directory "D:\wamp\www\dodo\v4.dodobook.net">
		Options +Indexes +FollowSymLinks +MultiViews
		AllowOverride None
		Order allow,deny
		Allow from all
    </Directory>
	RewriteEngine On
	RewriteRule ^(/web|/assets|/css|/js|/images|/ueditor|/upload|/favicon\.ico).* $0 [L]
	RewriteCond %{QUERY_STRING} ^(.*)$
	RewriteRule ^([^\?]*)$  /index.php$1?%1 [L]
</VirtualHost>


#这个根据需要进行
#RewriteRule ^(/assets|/css|/images|/themes|/file|/ueditor|/js|/favicon\.ico|/crossdomain\.xml|/upload).* $0 [L]

至于更多的版本和入口文件请各位自行探索。我试了一下把DirectoryIndex index-test.php index.php放在Directory也是可以的。

白头偕老这件事其实和爱情无关,只不过是忍耐。但忍耐却是一种爱。所以,真正爱你的人,其实就是愿意一直忍耐你的人。