2017-04-12 68 views
0

我想通过重写规则(mod_rewrite的)重定向启用在httpd.conf我的网址:
重写规则在Apache中不适用2.4的httpd.conf

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

TO:

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-_.]+)$ /$1/index_php_file.php?ab=ident_key_1024&ac=%1 [L,R=301] 

似乎重写URL。

关于我失踪的任何建议?

非常感谢。

回答

0

我找到了解决方案,它可能有助于某人。

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和URL RewriteRule改写为所需的格式并追加从查询中变量的值。

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