ThinkPHP URL rewriting

Source: Internet
Author: User
ThinkPHP is a free, open-source, fast, and simple object-oriented lightweight PHP development framework. It complies with the Apache2 open-source Protocol and is born for agile WEB application development and simplified enterprise application development. In use

ThinkPHP is a free, open-source, fast, and simple object-oriented lightweight PHP development framework. It complies with the Apache2 open-source Protocol and is born for agile WEB application development and simplified enterprise application development. In use

The result I want is nothing more than removing index. php from the URL path.

First, configure. htaccess

RewriteEngine onRewriteCond % {REQUEST_FILENAME }! -DRewriteCond % {REQUEST_FILENAME }! -FRewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L]

Because I am deployed on apache, I need to find LoadModule rewrite_module modules/mod_rewrite.so In the httpd. conf configuration file to remove the previous # And change AllowOverride None to AllowOverride All.

Currently, access to localhost/product is valid, but/index. php or/index. the paths obtained by php, Article, and U contain indexes. php, that is, localhost/index. php, there is another step, which needs to be done in conf/config. modify or add 'url _ model' => 2,

Because I tried to deploy ThinkPHP-based conist enterprise 2.0. php has such a configuration 'url _ model' => C ('token. false_static '), and TOKEN. the false_static value is set to 1 during initialization, so... The pattern is still 1, PATHINFO pattern.

Deploy in Sina SAE. It does not support. htaccess and only supports its own configuration file config. yaml. Therefore, add the following overwrite format code in config. yaml:

Handle:-rewrite: if (! Is_dir ()&&! Is_file () & path ~ "^ (. *) $") Goto "index. php/$1"

Related Article

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.