My website has two languages, Chinese and English If accessed using pathinfo, it should be like this Chinese: http://www.com/index.php/product/category/a1/ English: http://www.com/en.php/product/category/a2/ If the program turns on the rewrite mode, it should look like this http://www.com/cn/product/category/a1/ http://www.com/en/product/category/a2/ I have implemented it in apache, the rules are as follows
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^cn/(.*)$ index.php/ [L]
RewriteRule ^en/(.*)$ en.php/ [L]
</IfModule>
But in nginx I try two methods, such as method 1.
if (!-f $request_filename){
set $rule_0 1$rule_0;
}
if (!-d $request_filename){
set $rule_0 2$rule_0;
}
if ($rule_0 = "21"){
rewrite ^/cn/(.*)$ /index.php/ last;
}
rewrite ^/en/(.*)$ /en.php/ last;
Method 2.
location /cn/ {
if (!-e $request_filename){
rewrite ^/cn/(.*)$ /index.php/ last;
}
}
Neither method works, please give me a solution
大家讲道理2017-05-16 17:30:37
Method 2: You only wrote one? It should be no problem to write the following two items.
location /cn/ {
if (!-e $request_filename){
rewrite ^/cn/(.*)$ /index.php/ last;
}
}
location /en/ {
if (!-e $request_filename){
rewrite ^/en/(.*)$ /en.php/ last;
}
}