For example, your original path is http: // localhost/test/index. php/index/add
The current address is http: // localhost/test/index/add
How can I remove index. php?
IIS environment
If your server environment supports ISAPI_Rewrite, you can configure the httpd. Ini file and add the following content:
The code is as follows: |
Copy code |
RewriteRule (. *) $/index. php? S = $1 [I] |
In the later version of IIS, you can configure web. Config and add a rewrite node in the middle:
The code is as follows: |
Copy code |
<Rewrite> <Rules> <Rule name = "OrgPage" stopProcessing = "true"> <Match url = "^ (. *) $"/> <Conditions logicalGrouping = "MatchAll"> <Add input = "{HTTP_HOST}" pattern = "^ (. *) $"/> <Add input = "{REQUEST_FILENAME}" matchType = "IsFile" negate = "true"/> <Add input = "{REQUEST_FILENAME}" matchType = "IsDirectory" negate = "true"/> </Conditions> <Action type = "Rewrite" url = "index. php/{R: 1}"/> </Rule> </Rules> </Rewrite> |
Nginx environment
In earlier versions of Nginx, PATHINFO is not supported, but you can configure forwarding rules in Nginx. conf:
The code is as follows: |
Copy code |
Location /{//..... Partial code omitted If (! -E $ request_filename ){ Rewrite ^ (. *) $/index. php? S = $1 last; Break; } } |
In fact, the URL is forwarded to the compatible mode provided by ThinkPHP. This method can be used to solve other WEB server environments that do not support PATHINFO.
If your ThinkPHP is installed in the second-level Directory, set the pseudo-static method of Nginx as follows, where youdomain is the directory name.
The code is as follows: |
Copy code |
Location/youdomain /{ If (! -E $ request_filename ){ Rewrite ^/youdomain/(. *) $/youdomain/index. php? S = $1 last; } } |
Apache environment
1. The mod_rewrite.so module is loaded in the httpd. conf configuration file. // Configure it in APACHE.
# LoadModule rewrite_module modules/mod_rewrite.so remove the preceding alert code
2. Change AllowOverride None to All // Configure AllowOverride in APACHE (note that AllowOverride is set to ALL in other places)
The code is as follows: |
Copy code |
<Directory "D:/server/apache/cgi-bin"> AllowOverride none to AllowOverride ALL Options None Order allow, deny Allow from all </Directory> |
3. Make sure that URL_MODEL is set to 2 and write it in the configuration file of the project.
The code is as follows: |
Copy code |
Return Array ( 'URL _ model' => '2 ', ); |
4. The htaccess file must be placed in the directory with the link.
In this file, add:
The code is as follows: |
Copy code |
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond % {REQUEST_FILENAME }! -D RewriteCond % {REQUEST_FILENAME }! -F RewriteRule ^ (. *) $ index. php/$1 [QSA, PT, L] </IfModule> |
In windows, you cannot create a file starting with a dot.
Then, in DOS, perform the rename xxxx. xxxx. htaccess operation