Apache:帮助转换 .htaccess

发布于 2024-10-05 04:38:24 字数 563 浏览 0 评论 0原文

我正在尝试将以下 .htaccess 重写规则转换为适当的 NGINX 格式。

# Redirect /signup/PLANNAME or /signup/PLANNAME/ --> /signup/index.php?account_type=PLANNAME
RewriteEngine on
RewriteRule ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 [NC,L]

我尝试使用以下 NGINX 规则,但它不起作用。

rewrite  ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

知道我做错了什么才能使 NGINX 正常工作吗?查看官方文档并没有多大帮助,因为该文档不是很详尽。

I'm trying to convert the following .htaccess rewrite rule to the appropriate NGINX format.

# Redirect /signup/PLANNAME or /signup/PLANNAME/ --> /signup/index.php?account_type=PLANNAME
RewriteEngine on
RewriteRule ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1 [NC,L]

I tried using the following NGINX rule, but it's not working.

rewrite  ^signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

Any idea what I'm doing wrong to make this work with NGINX? Looking at the official documentation isn't very helpful since the documentation is not very through.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奶气 2024-10-12 04:38:24

由于您不在 .htaccess 文件内,因此必须使用绝对路径。像这样:

rewrite  ^/signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

As you're not within a .htaccess file, you have to use absolute paths. As such:

rewrite  ^/signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;
阳光①夏 2024-10-12 04:38:24

我发现了问题,我缺少开头的正斜杠(/)。

回答:

rewrite  ^/signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;

I found the problem, I was missing the forward slash (/) at the beginning.

Answer:

rewrite  ^/signup/([A-Za-z]+)/?$ /signup/index.php?account_type=$1  last;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文