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

How to remove index.php in yii

王林
王林Original
2020-08-15 15:18:283747browse

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"6e3512f89a97c220f19675c12d5a1a4cbb15ed4aadeed04b3991578461de0768 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;,
            ],
        ],           
 )

(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

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!

Statement:
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