Help convert .htaccess rules to nginx rules
PHPz
PHPz 2017-05-16 17:28:02
0
3
923

This rule is based on the rereite rules of the Blue Dolphin shopping guide program.

I want to convert the following .htaccess rules into nginx rules, please help...

<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/ [L]
</IfModule>
PHPz
PHPz

学习是最好的投资!

reply all(3)
刘奇

A more accurate statement is: how to convert Apache's rewrite rules into nginx's. ——.htaccess is just a means and need not be mentioned too much, but it must be emphasized that the module involved is rewrite, because if it is another module, nginx may not have corresponding functions.

Two ideas:

  1. Converter http://www.anilcetin.com/convert-apache-htaccess-to-nginx/
  2. This rewrite rule is very WordPress-like. You can check "wordpress nginx rewrite" and learn to modify it to suit you.
曾经蜡笔没有小新

The above rule means that if the file or folder corresponding to the URI does not exist, rewrite it. Apache's %{REQUEST_FILENAME} corresponds to $uri in nginx, so your above rules can be configured with the following try_files

try_files    $uri $uri/  /index.php/$uri&$args;

The function of try_files is to check whether the files exist in order and return the first found file or folder (a trailing slash indicates a folder). If all files or folders are not found, an internal reset will be performed. Directed to the last parameter.

$args represents the parameters in the url.

曾经蜡笔没有小新
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 ^/(.*)$ /index.php/ last;
}

Apache rewrite rules converted to Nginx
http://www.51ask.org/apache2n...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template