ThinkPHP5 hidden interface inside the index.php

Source: Internet
Author: User

Hide index.php

The official introduction is this: http://www.kancloud.cn/thinkphp/thinkphp5_quickstart/145250

You can remove the entry file from the URL address index.php , but you need to configure the Web server's rewrite rules for additional configuration.

As an Apache example, you need to add a file to the same sibling of the portal file .htaccess (the file is officially brought by default), as follows:

<IfModule mod_rewrite.c>Options +FollowSymlinks -MultiviewsRewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]</IfModule>

Next, you can use the following URL address to access the

http://tp5.com/index/index/indexhttp://tp5.com/index/index/hello

If the version you are using apache does not hide properly using the above method index.php , you can try to configure the file using the following method .htaccess :

<ifmodule mod_rewrite.c>Options +followsymlinks-multiviewsRewriteengineOnRewritecond%{request_filename}!-dRewritecond%{request_filename}!-fRewriterule ^ (. *) $ index.php?/$[Qsa,pt,l]</IfModule>

But it still does not work, to find such an article (http://bbs.php100.com/simple/?t300372.html):
Apache Rewrite quasi-static configuration
1. Mod_rewrite Introduction and Configuration
The main function of Rewirte is to implement the URL jump and hide the real address, based on the Perl language of the regular
An expression specification. Usually help us achieve quasi-static, quasi-directory, domain name jump, prevent hotlinking, etc.
If a normal access address is
*/php100.php?id=2
Can be turned into:
*/php100_2.html
or turn into:
*/php100_2/

Apache Configuration:
Supports httpd.conf configuration and directories. htaccess Configuration
Enable rewrite
# LoadModule Rewrite_module modules/mod_rewrite.so
Remove the previous #
LoadModule Rewrite_module modules/mod_rewrite.so
Enable. htaccess
AllowOverride None modified to: allowoverride all


2, the use of mod_rewrite rules
Rewriteengine on
Rewritecond%{http_host}!^www.php100.com [NC]
Rewriterule ^/(. *) http://www.php100.com/[L]
Start the rewrite engine to determine if the host jumps to
Rewriteengine on
Rewriterule ^/test ([0-9]*). html$/test.php?id=$1
Rewriterule ^/new ([0-9]*)/$/new.php?id=$1 [R]


3. mod_rewrite Rule modifier
1) R Force external redirection
2) F disable URL, return 403HTTP status code.
3) G force URL is gone, return 410HTTP status code.
4) P forces the use of proxy forwarding.
5) L indicates that the current rule is the last rule, which stops the rewrite of the rule after parsing.
6) N re-run the rewrite process starting with the first rule.
7) C is associated with the next rule

If rule matching is handled correctly, the following modifier is invalid

8) T=mime-type (Force MIME type) enforce MIME type
9) NS is only used for internal sub-requests
NC is case insensitive
One) QSA Append request string
NE not output escape special character \%3d$1 equivalent to =$1
-----------------------------------------------------------------------------
This is the last thing to add to the process:

Remove #LoadModule rewrite_module modules/mod_rewrite.so in front of the
Then change the permissions allowoverride none to allowoverride all, restart Apache

ThinkPHP5 hidden interface inside the index.php

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.