Home >Backend Development >PHP Tutorial >Summarize the steps to hide the index.php file

Summarize the steps to hide the index.php file

巴扎黑
巴扎黑Original
2016-12-01 11:28:412248browse

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 There is "AllowOverride All" in
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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn