小画家

求知若饥,虚心若愚

YII2 隐藏index


Please add the following lines in ‘.htaccess’ file inside the ‘web’ directory of yii2.0 application.

在YII front  /web 下面建立 .htaccess   在cmd  里面找到路径: echo>.htaccess

RewriteEngine on
# If a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward it to index.php
RewriteRule . index.php


在: main.php 文件里面写入:


.................
'urlManager' => [		
	'class' => 'yii\web\UrlManager',
		// Disable index.php
	'showScriptName' => false,
		// Disable r= routes
	'enablePrettyUrl' => true,
	'rules' => array(
				
			),
	],
.................


||||||||||||||||||

或者:在APACHE  里面:

<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs/test.dev/frontend/web"
ServerName test.dev
<Directory "E:/xampp/htdocs/test.dev/frontend/web">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all

#RewriteEngine on
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteRule . index.php
# DirectoryIndex index.php    #####加入  # 号部份
</Directory>

</VirtualHost>




阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liuxiaojun828/article/details/52355829
个人分类: YII
上一篇yii2关闭debug后return redirect()不能跳转,服务器报500错误的解决办法
下一篇discuz 与YII 的同步登录
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭