Home > php教程 > PHP开发 > Yii method to hide index.php in URL

Yii method to hide index.php in URL

高洛峰
Release: 2016-12-30 17:02:23
Original
1826 people have browsed it

The example in this article describes 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(
      &#39;<controller:\w+>/<id:\d+>&#39;=>&#39;<controller>/view&#39;,
      &#39;<controller:\w+>/<action:\w+>/<id:\d+>&#39;=>&#39;<controller>/<action>&#39;,
      &#39;<controller:\w+>/<action:\w+>&#39;=>&#39;<controller>/<action>&#39;,
      ),
),
Copy after login

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
Copy after login

I hope this article will be helpful to everyone’s PHP program design based on the Yii framework.

For more articles related to Yii’s method of hiding index.php in the URL, please pay attention to 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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template