On thinkphp's URL rewriting _php skills

Source: Internet
Author: User

All I want is to get rid of the index.php in the URL path.

The first is the configuration. htaccess

Copy Code code as follows:

<ifmodule mod_rewrite.c>
Rewriteengine on
Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php/$1 [qsa,pt,l]
</IfModule>

Because I am deployed on Apache, I need to find LoadModule rewrite_module in httpd.conf config file modules/mod_rewrite.so remove the front #, Find allowoverride None to allowoverride all.

The access localhost/product is now valid, but __app__ or __url__ or u get out of the path contains index.php, which is localhost/index.php, there is a step that needs to be conf/ Config.php inside Modify or add ' Url_model ' =>2,

And because I was trying to deploy the Conist Enterprise version 2.0 based on thinkphp, there was a configuration ' Url_model ' =>c (' token.false_static ') in config.php, and Token.false_ The value of the static is set to 1 at initialization time, so ... Pattern is still 1,pathinfo mode.

in the Sina SAE deployment , does not support. htaccess, only support its own profile config.yaml, so add the following rewrite format code in CONFIG.YAML:

Copy Code code as follows:

Handle
-Rewrite:if (!is_dir () &&!is_file () && path~ "^ (. *) $") goto "index.php/$1"

is not super simple, if you want to learn more about other pseudo static knowledge, please read the following article to recommend it.

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.