重写规则未应用于 Apache 2.4 httpd.conf

Rewriterule not applied in Apache 2.4 httpd.conf

我想通过在 httpd.conf 我的 URL 中启用的 RewriteRule (mod_rewrite) 重定向:

https://mysite.domain.tld/index_php_file.php?ab=ident_keys&ac=5GU7VBNAH45DA5

收件人:

https://mysite.domain.tld/index_php_file.php?ab=ident_key_1024&ac=5GU7VBNAH45DA5

我尝试了很多规则,但没有成功:

RewriteCond %{HTTP_HOST} hmysite.domain.tld
RewriteRule ^/index_php_file\.php\?ab=ident_keys&ac=$ https://hmysite.domain.tld/index_php_file.php?ab=ident_key_1024&ac= [R=301,L,QSA]

也不

RewriteCond %{QUERY_STRING} ^ac=(.*)$
RewriteRule ^/?([a-z-0-9-_.]+)$ //index_php_file.php?ab=ident_key_1024&ac=%1 [L,R=301]

好像改写了URL。

有什么关于我遗漏的建议吗?

非常感谢。

我找到了解决方案,它可能会对某人有所帮助。

RewriteCond %{QUERY_STRING} ac=([A-Z0-9]+)
RewriteRule ^/?([-a-zA-Z0-9_+]+)$ index_php_file.php?ab=ident_key_1024&ac= [R=301,L]

RewriteCond 查找字符串(仅包含大写字符和数字)并将 URL RewriteRule 重写为所需格式并附加值就足够了来自查询的变量。

不要忘记在 Apache 中启用 mod_rewrite 模块。当然也需要重启才能生效