关闭

YII2 隐藏index

412人阅读 评论(0) 收藏 举报
分类:


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>




0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:145604次
    • 积分:2859
    • 等级:
    • 排名:第12908名
    • 原创:117篇
    • 转载:179篇
    • 译文:4篇
    • 评论:4条
    最新评论