简体   繁体   中英

.htaccess to nginx rewrite rules

I want to convert a simple .htaccess file (rules) to be used with nginx. I try to access an online tool after googleit but that website is down. So, if anyone cand help, i would appreciate. Thank you. Here is my .htaccess file:

Options +FollowSymLinks +ExecCGI

<IfModule mod_rewrite.c>
  RewriteEngine On

  # we skip all files with .something
  RewriteCond %{REQUEST_URI} \..+$
  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule .* - [L]

  # we check if the .html version is here (caching)
  RewriteRule ^$ index.html [QSA]
  RewriteRule ^([^.]+)$ $1.html [QSA]
  RewriteCond %{REQUEST_FILENAME} !-f

  # no, so we redirect to our front web controller
  RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

Please, try these rules:

# Deny all files that started with dot
location ~ /\. {
        deny all;
}
# Try $uri - is file, $uri/ - is dir, index.html - caching, $uri.html caching, index.php -last
location / {
        try_files $uri $uri/ index.html $uri.html index.php;
}

Please, try these rules:

# nginx configuration

location ~ \.html$ {
}

location / {
  if ($request_uri ~ "\..+$"){
    rewrite ^/$ /index.html;
  }
  rewrite ^/([^.]+)$ /$1.html;
  if (!-e $request_filename){
    rewrite ^(.*)$ /index.php break;
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM