thinkphp5.0 How to hide index.php portal files

Source: Internet
Author: User

Hide portal Files public/index.php. htaccess files for siblings [Apache]

Method 1:

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

Method 2:
    1. The mod_rewrite.so module is loaded in the httpd.conf configuration file
    2. allowoverride None Change None to all
    3. Save the following content as a. htaccess file in the same sibling directory as the application portal file
<IfModule mod_rewrite.c>Options +FollowSymlinks -MultiviewsRewriteEngine onRewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^(.*)$ index.php?/$1 [QSA,PT,L]</IfModule>

[IIS]

If your server environment supports Isapi_rewrite, you can configure the Httpd.ini file to add the following:

RewriteRule (.*)$ /index\.php\?s=$1 [I]

Under high versions of IIS, you can configure Web. config to add rewrite nodes in the middle:

<Rewrite><Rules><RuleName="Orgpage"stopprocessing="True" ><MatchUrl="^ (. *) $"/><Conditionslogicalgrouping="MatchAll" ><Addinput="{Http_host}"pattern="^ (. *) $"/><Addinput="{Request_filename}"Matchtype="Isfile"Negate="True"/><Addinput="{Request_filename}" matchtype=" isdirectory " negate=" true "/> </conditions> <action type="Rewrite" url="index.php/{r:1}"/> </rule>  </ rules> </rewrite>            
[Nginx]

In Nginx low version, PathInfo is not supported, but can be implemented by configuring a forwarding rule in nginx.conf:

  location / { // …..省略部分代码   if (!-e $request_filename) {   rewrite  ^(.*)$  /index.php?s=/$1  last;   break; } }

In fact, the internal is forwarded to the thinkphp to provide a compatible URL, in this way, you can solve other non-support PathInfo Web server environment.

If your app is installed in a level two directory, Nginx the pseudo-static method is set as follows, where youdomain the directory name is located.

location /youdomain/ {    if (!-e $request_filename){        rewrite  ^/youdomain/(.*)$ /youdomain/index.php?s=/$1 last; }}


https://www.kancloud.cn/manual/thinkphp5/118012 这个是官方手册地址


thinkphp5.0 How to hide index.php portal files

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.