In order to make the URL more beautiful, we do not want to see the URL of the word php (forced gecko).
However, when our PHP project has multiple entry files, (if there are index.php, admin.php, app.php, api.php four entry files), in the non-processing state, the URL will show such a scene:
www.example.com/index.php/xxx/xxx/...
www.example.com/admin.php/xxx/xxx/...
www.example.com/app.php/xxx/xxx/...
www.example.com/admin.php/xxx/xxx/...
At this point, we can use the rewrite function of our server, to transform Url,apache and nginx have this function. I'm using nginx here.
In the nginx.conf file, write this:
Server {Listen the; server_name localhost; Root"D:/phpstudy/www/blog/webroot"; Index index.php; ########################################## #隐藏. PHP Location/ { if(!-e $request _filename) {# # # When the project has multiple portal files # admin.ph P Entrance Rewrite^/admin/(. *) $/admin.php/$1Last ; # app.php Entrance # rewrite^/app/(. *) $/app.php/$1Last ; # api.php Entrance # rewrite^/api/(. *) $/api.php/$1Last ; # # # Before the URL filter, then go index.php entrance rewrite^/(. *) $/index.php/$1Last ; }} ######################################### #pathinfo mode location~ \.php ($|/) {Fastcgi_pass127.0.0.1:9000; Fastcgi_index index.php; Fastcgi_split_path_info^ (. +\.php) (. *)$; Fastcgi_param path_info $fastcgi _path_info; Fastcgi_param script_filename $document _root$fastcgi_script_name; Include Fastcgi_params; }}
"Nginx rewrite URL" when the project has multiple portal files