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:
- The mod_rewrite.so module is loaded in the httpd.conf configuration file
- allowoverride None Change None to all
- 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