Home > PHP Framework > YII > How to remove index.php in yii

How to remove index.php in yii

王林
Release: 2020-08-15 15:18:28
Original
3811 people have browsed it

Yii method to remove index.php: 1. Enable the mod_rewrite module of apache and restart apache; 2. Edit the /config/web.php file in the project; 3. At the same level as the index.php file Add the [.htaccess] file to the directory.

How to remove index.php in yii

Specific method:

(Recommended tutorial: php graphic tutorial)

1. Enable apache's mod_rewrite module

  • Remove the "#" symbol before LoadModule rewrite_module modules/mod_rewrite.so

  • Ensure DocumentRoot "/Library/WebServer /Documents" contains "AllowOverride All"

  • Restart apache, command: sudo apachectl restart

2. Add code to /config/web.php in the project:

components'=>array(            
  ...
'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                &#39;<controller:\w+>/<action:\w+>&#39;=>&#39;<controller>/<action>&#39;,
            ],
        ],           
 )
Copy after login

(Video tutorial recommendation: php video tutorial)

3. Add the file ".htaccess" in the same directory as the index.php file (/web/) with the following content:

Options +FollowSymLinks
IndexIgnore */*
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
Copy after login

The above is the detailed content of How to remove index.php in yii. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template