How to hide index.php in URL in Yii

小云云
Release: 2023-03-17 17:30:02
Original
1574 people have browsed it

We have shared a lot of knowledge about the Yii framework before, and also specially produced a Yii framework topic for everyone to learn. In this article, we will give an example of how Yii hides index.php in the URL. Share it with everyone for your reference, the details are as follows:

1. Modify the main.php under config/:

'urlManager'=>array(

' urlFormat'=>'path',

'showScriptName'=>false,

'rules'=>array(

'/'=>'/view',

'//'=>'/',

'/'=>'/',

),

),

##2. Modify the content of the .htaccess file in the root directory of the website as follows:


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 content is how Yii hides index.php in the URL. I hope it can help everyone.

Related recommendations:

Yii framework framework module development

How to load Yii’s own verification code function

Summary of database query operations of PHP Yii framework

The above is the detailed content of How to hide index.php in URL 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