htaccess正则表达挑战
我正在尝试写一个.htaccess的正则表达式,但仍然无法做到。我花了很多时间试图弄清楚道路。当然,使用正则是,很难找到一个确切的答案。这就是为什么我真的很感谢您的帮助。
场景是:有一个脚本(WordPress插件)向我的API网关提出了帖子请求,看起来像:
https://example.com/?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
一切都在起作用,但是我的结局有一个API更新,现在它不会执行它。 但是,在进行了多次测试之后,我发现同一请求在执行方式时可以工作:
https://example.com/wp-admin/admin-ajax.php?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
因为有很多人安装了WordPress插件,并且他们的许可证被停用了,所以他们无法进行自动更新,而唯一的方法是重定向向将使插件活动的请求。
要解决的问题是我们如何从以下方式重定向邮政请求:
https://example.com/?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
使用:
https://example.com/wp-admin/admin-ajax.php?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
使用HTACCESS REGEX规则。
关于如何解决这个问题的任何想法?
I'm trying to write an .htaccess regex, but still can't make it. I spent many hours trying to figure out the way. Of course, with regex, it is hard to find an exact answer. That's why I would really appreciate your help.
The scenario is: there is a script (WordPress plugin) making a POST request to my API gateway which looks like:
https://example.com/?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
Everything was working, but there was an API update on my end and now it won't execute it.
However, after doing multiple tests, I discovered that the same request works when executed this way:
https://example.com/wp-admin/admin-ajax.php?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
Because there are many people who have installed the WordPress plugin and their license was deactivated, they cannot do an automatic update, and the only way is to redirect the request to the one that will make their plugin active.
The problem to be solved is how we can redirect post requests from:
https://example.com/?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
to:
https://example.com/wp-admin/admin-ajax.php?edd_action=check_license&item_id=111&license=UN_222&url=some.url.com
Using htaccess regex rules.
Any ideas on how to approach this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在.htaccess的顶部尝试此重定向规则:
如果给出的查询字符串模式成功地匹配,则将将URI重定向到
/wp-admin/admin-ajax.php
。You can try this redirect rule at top of your .htaccess:
This rule will redirect landing page URI to
/wp-admin/admin-ajax.php
if given query string pattern matches successfully.