Mod rewrite 重写规则未在Apache 2.4 httpd.conf中应用
我想通过httpd.conf中启用的重写规则(mod_rewrite)重定向我的URL:Mod rewrite 重写规则未在Apache 2.4 httpd.conf中应用,mod-rewrite,httpd.conf,apache2.4,Mod Rewrite,Httpd.conf,Apache2.4,我想通过httpd.conf中启用的重写规则(mod_rewrite)重定向我的URL: 识别键&ac=5GU7VBNAH45DA5 致: 识别键1024&ac=5GU7VBNAH45DA5 我曾尝试过一些规则,但运气不佳: RewriteCond %{HTTP_HOST} hmysite.domain.tld RewriteRule ^/index_php_file\.php\?ab=ident_keys&ac=$ https://hmysite.domain.tld/index_ph
识别键&ac=5GU7VBNAH45DA5 致: 识别键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]
也不是
似乎要重写URL
对我遗漏的东西有什么建议吗
非常感谢。我找到了解决方案,它可能会帮助别人
RewriteCond %{QUERY_STRING} ac=([A-Z0-9]+)
RewriteRule ^/?([-a-zA-Z0-9_+]+)$ index_php_file.php?ab=ident_key_1024&ac=$1 [R=301,L]
只需使用RewriteCond
查找字符串(仅包含大写字符和数字),然后将URLRewriteRule
重写为所需格式,并从查询中附加变量值即可
不要忘记在Apache中启用mod_rewrite
模块。当然,要想生效,重启也是必要的
RewriteCond %{QUERY_STRING} ac=([A-Z0-9]+)
RewriteRule ^/?([-a-zA-Z0-9_+]+)$ index_php_file.php?ab=ident_key_1024&ac=$1 [R=301,L]