【问题标题】:translate apache2 rewrite rules翻译 apache2 重写规则
【发布时间】:2012-01-12 17:13:59
【问题描述】:

我有这个文件 .htaccess 用于 apache:

# 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]

如何将其转换为 .htaccess 用于 nginx ?

我试过这个:

  location / {
    rewrite ^/$ /index.html;
    rewrite / /RewriteRule;
    rewrite ^/(.*)$ /index.php last;
  }

你觉得对吗?

非常感谢!

【问题讨论】:

    标签: apache nginx rewrite


    【解决方案1】:

    您不需要重写这些东西,只需 try_files

    try_files /index.html$is_args$args $uri.html$is_args$args $uri /index.php$is_args$args;
    

    【讨论】:

      猜你喜欢
      • 2013-02-27
      • 2016-07-22
      • 1970-01-01
      • 1970-01-01
      • 2013-07-12
      • 2011-11-17
      • 2011-11-25
      • 1970-01-01
      • 2014-08-10
      相关资源
      最近更新 更多