YII2 隐藏index

来源:互联网 发布:面向对象编程步骤 编辑:程序博客网 时间:2024/06/16 09:51


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 directlyRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-d# Otherwise forward it to index.phpRewriteRule . 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 ExecCGIAllowOverride AllOrder allow,denyAllow from all#RewriteEngine on#RewriteCond %{REQUEST_FILENAME} !-f#RewriteCond %{REQUEST_FILENAME} !-d#RewriteRule . index.php# DirectoryIndex index.php    #####加入  # 号部份</Directory></VirtualHost>




0 0
原创粉丝点击