For example, your original path is http://localhost/test/index.php/index/add
, and you want to it like this http://localhost/test/index/add
.
Configure Apache
Make sure that httpd.conf
configuration file loaded mod_rewrite.so
module, uncommented:
# LoadModule rewrite_module modules/mod_rewrite.so
Modify AllowOverride None
to AllowOverride All
Configure ThinkPHP
Make sure URL_MODEL set to 2, in the project's configuration file:
return Array( 'URL_MODEL' => '2', );
Modify .htaccess
Add to .htaccess
file:
RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]