thinkphp How to Implement "http://localhost/index.php?/module/Operation &quo ... Change to "http://localhost/module/operation"
I want to change the URL into this form, it will look comfortable, but I do not know how to achieve.
Is the CONIFG inside add parameter, or in Nginx inside with rewrite?
Reply content:
thinkphp How to Implement "http://localhost/index.php?/module/Operation &quo ... Change to "http://localhost/module/operation"
I want to change the URL into this form, it will look comfortable, but I do not know how to achieve.
Is the CONIFG inside add parameter, or in Nginx inside with rewrite?
1. In the configuration file, change the URL mode to
' Url_model ' = ' 2 ',//rewrite mode
2.Apache Server, save the following content as a. htaccess file in the sibling directory of the portal file
Rewriteengine Onrewritecond%{request_filename}!-drewritecond%{request_filename}!-fRewriteRule ^ (. *) $ index.php/$1 [Qsa,pt,l]
Configuration in nginx.conf
Location/{//... omit part of the code if (!-e $request _filename) { rewrite ^ (. *) $/index.php?s=$1 last ; break; } }
Resources:
Http://doc.thinkphp.cn/manual/url_rew ...
Http://doc.thinkphp.cn/manual/hidden_ ...
Suggest landlord to look at the manual side first, after all, this is the basis of things.
In a rewrite way.
Official Document: Hide index.php
This needs to be in the Nginx configuration inside the rewrite.
The original format ensures that the framework can function properly without the rewrite module on the server (Apache/nginx, etc.).
The rewrite can resemble:
location/your_app/{ if (!-f $request _filename) {#如果请求到css等资源则略过 rewrite ^/your_app/(. *) $/your_app/ index.php?$1;} }
Nginx on rewrite recommended to use the official and I recommend the Try_files method;)
Location/{ try_files $uri $uri//index.php$uri? $args;}
See why you use Try_files instead of using if to judge
Portal 1:http://wiki.nginx.org/httpcoremodule# ...
Portal 2:http://wiki.nginx.org/ifisevil
Turn on route matching, then open rewrite mode in Apache