繁体   English   中英

如何将以下简单的 Nginx 重写条件和规则转换为 Apache .htaccess

[英]How to convert the following simple Nginx rewrite conditions and rules to Apache .htaccess

我想将以下 Ngnix 重写规则和条件转换为 Apache .htaccess,但我无法成功。

location /app/ {
  if (!-e $request_filename) {
    rewrite ^ /app/index.html break;
  }
}

location ~ /app/account/(.*?)$ {
  try_files $uri $uri/ /index.php?$query_string;
}

location ~ /app/pay/(.*?)$ {
  try_files $uri $uri/ /index.php?$query_string;
}

您能否仅根据您显示的代码尝试以下操作。 我也不是 nginx 的专家,但我在这里尽我所能:) 请确保在测试 URL 之前清除浏览器缓存。

显然,如果您可以为我们提供 URL 示例,其中包含您想要重写/重定向的 url 到 url 的逻辑,那么它会更容易更好地理解它,并且对测试也有帮助。

RewriteEngine ON
##First rule here...
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ /app/index.html [L]

##Second rule here....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^app/account/(.*)/?$ index.php?$1 [L]

##Third rule here....
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^app/pay/(.*)/?$  index.php?$1 [L]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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