search

Home  >  Q&A  >  body text

How to convert apache rewrite to nginx rewrite

I am a newbie. I would like to know how to convert apache rewrite to nginx. For example, how to convert the following apache rules:

 <IfModule mod_rewrite.c>
     RewriteEngine On
     RewriteCond %{REQUEST_URI} !dispatch\.php$
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteRule .* dispatch.php [L,QSA]
 </IfModule>
迷茫迷茫2753 days ago596

reply all(2)I'll reply

  • 世界只因有你

    世界只因有你2017-05-16 17:05:01

    It’s simple. Understand your Apache httpd rules, and then write its functions using nginx rules. It’s almost the same thing as translation.

    Your rule means that if the accessed URI does not end with dispatch.php and the accessed file does not exist, then it will be redirected to dispatch.php. You can write this directly in nginx:

    try_files $uri /dispatch.php;
    

    reply
    0
  • 高洛峰

    高洛峰2017-05-16 17:05:01

    Apache Rewrite转Nginx Rewrite

    reply
    0
  • Cancelreply