如何在htaccess中配置路由?

时间:2018-04-17 20:46:46

标签: .htaccess opencart2.3

我需要知道如何在访问时配置htaccess:

http://teste.com.br/route=feed/rest_api/count_products&key=123456

最多的动作是:

http://teste.com.br/index.php?route=extension/feed/rest_api/count_products&key=123456

我需要这个来配置与另一个系统的集成。

  • 记住我需要一些适用于rest_api
  • 中所有方法的泛型

我尝试了这个但不行:

RewriteRule ^route=feed/? index.php?route=extension/feed/$1  [L]

1 个答案:

答案 0 :(得分:0)

您可以将此规则用作最高规则

RewriteEngine On

RewriteCond %{QUERY_STRING} ^(route)=(feed/[^&]*&key=\d+)$ [NC]
RewriteRule ^(?:index\.php)?$ %{REQUEST_URI}?%1=extension/%2 [L,NC]