Home >Backend Development >PHP Tutorial >Summarize the steps to hide the index.php file
Summarize the steps to hide the index.php file
1. Turn on the mod_rewrite module of apache
Remove the "#" symbol in front of LoadModule rewrite_module modules/mod_rewrite.so
Make sure
2. Add the code in /protected/config/main.php in the project:
'components'=>array(
' urlformat '= & gt;' path ',
' showscriptname '= & gt; false, // Note that False should not include quotes
' urlsuffix '= & gt;'. HTML ',
' rules' = & gt; Array (
' sites'=>'site/index',
Add the file ".htaccess" in the same directory as the .php file with the following content :
Options +FollowSymLinks IndexIgnore */* ‐ ‐ ‐ ‐ ‐ ‐‐‐‐‐ RewriteCond %{REQUEST_FILENAME} !- f
RewriteCond %{REQUEST_FILENAME} !-d forward it to index.php
RewriteRule . index.php
Copy the code
This way you can hide the index.php entry file.