rewrite - nginx pseudo-static problem
習慣沉默
習慣沉默 2017-05-16 17:28:37
0
1
606

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

習慣沉默
習慣沉默

reply all(1)
大家讲道理

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;
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template