Yii 1.0 pseudo Static or yii configuration URL rewrite

Source: Internet
Author: User
Tags yii

Learning that yii today, the URL is too troublesome, want to configure themselves, so Baidu a bit, and then their own summary, save the back of the configuration of the time to see.


There is an important component in the YII framework: URL Management (URL management)


Yii pseudo-Static is only necessary to configure this can be.


Not configured before this is the way:



The URL after a successful configuration is this:



First step: Configure URL Management (URL management)


Just configure it in the main.php file below the Config folder.


' Components ' = = Array (        ' urlmanager ' = ' = '            showscriptname ' = ' false,//here is the hidden index.php that path            ' Urlformat ' + ' path ',            ' rules ' and ' = '                <controller:\w+>/<id:\d+> ' + ' <controller>/ View ',                ' <controller:\w+>/<action:\w+>/<id:\d+> ' = ' <controller>/<action> ',                ' <controller:\w+>/<action:\w+> ' = ' <controller>/<action> '            ]        ,        ' User ' = = Array (                        //Enable cookie-based authentication            ' allowautologin ' = True        ), <span style= " Font-family:arial, Helvetica, Sans-serif; >) </span>

Step two: Perform Apache configuration


There is a file in Yii:. htaccess is used to configure the Apache server specifically, this file is configured to enter the following code


<ifmodule mod_rewrite.c>options +followsymlinksindexignore */*rewriteengine on# If a directory or a file exists, use It directlyrewritecond%{request_filename}!-frewritecond%{request_filename}!-d# otherwise forward it to INDEX.PHPREWR Iterule. Index.php</ifmodule>

Once this file has been configured, be sure to turn on the rewrite module in Apache:



And then it's OK.


The configuration of the entire URL is complete.


Yii 1.0 pseudo Static or yii configuration URL rewrite

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.