Modify the apache configuration file to remove index.php from thinkphp url

  • 2020-12-09 00:48:14
  • OfStack

Such as your original path is http: / / localhost test/index php/index/add
So now address is http: / / localhost test/index/add
How do you get rid of index.php?

1. mod_rewrite. so module is loaded in httpd. conf configuration file // to be configured in APACHE


#LoadModule rewrite_module modules/mod_rewrite.so Take the warning off the front 

2. AllowOverride None change None to All // Configure APACHE in APACHE (note that AllowOverride in other places is also set to ALL)


<Directory "D:/server/apache/cgi-bin">
AllowOverride none   change    AllowOverride ALL
Options None
Order allow,deny
Allow from all
</Directory>

3. Make sure URL_MODEL is set to 2 and write in the project profile


return Array(
   'URL_MODEL' => '2',
);

4.htaccess files must be placed in the following directory
Add in this file:


<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>

Supplement: you cannot create a file starting with a dot under windows. You can create a file at will
Then in DOS operate rename xxxx.xxxx.htaccess


Related articles: