Yii Removal index.php portal script displayed as SEO friendly URL

Source: Internet
Author: User
Tags yii

1. Remove the portal script need to rewrite the URL, if your webserver software when Apache, you must configure httpd.conf, search "LoadModule rewrite_module modules/mod_rewrite.so", Then remove the "#" [PS: Comment symbol] in front of this line:

2. In the Yii Web application Master Profile main.php[path\to\protected\config\main.php], use Urlmanager to add an array configuration option ' showscriptname ' = False

1' Urlmanager ' =Array(2' Urlformat ' = ' path ',3' Showscriptname ' =false,//Remove the display of the portal script index.php4' Rules ' =Array(5' post/<id:\d+>/<title:.*?> ' = ' Post/view ',6' posts/<tag:.*?> ' = ' post/index ',7' <controller:\w+>/<action:\w+> ' = ' <controller>/<action> ',8),9),

3. Copy the. htaccess file from the other path of the project to the same level of path as the portal script index.php, overwriting the contents with the following code:

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

For a definition of Apache rewrite rules, see: Http://httpd.apache.org/docs/2.2/en/mod/mod_rewrite.html#rewriterule and/http Www.maxi-pedia.com/FollowSymLinks

Also, if you do not know how to create a file without a file name under Windows, you can create it under a path in the following way:

Yii Removal index.php portal script displayed as SEO friendly URL

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.