Htaccess rewriterule wordpress问题

问题描述 投票:1回答:2

我试图通过wordpress中的htaccess文件进行这个重写我有以下网址:https://domain_name.com/index.php/field/value_to_be_written我希望它在内部重定向到:https://domain_name.com/index.php/field/?get_value=value_to_be_written

我有以下代码,但它给了我500错误:

RewriteRule ^index.php/field/(.*)$ index.php/field/?get_value=$1 [L]

任何帮助都会很棒。提前致谢。

php wordpress .htaccess http-status-code-500
2个回答
2
投票

你只需要领先的斜杠:

RewriteRule ^/index\.php/field/(.*)$ /index.php/field/?get_value=$1 [L]

摘自https://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewriterule

<!-- language: lang-none -->
+-----------------------------+------------------------+
| Given Rule                  | Resulting Substitution |
+-----------------------------+------------------------+
| ^/somepath(.*) otherpath$1  | invalid, not supported |
| ^/somepath(.*) /otherpath$1 | /otherpath/pathinfo    |
+-----------------------------+------------------------+

1
投票
RewriteEngine On
RewriteRule ^/index\.php/field/?get_value=$1 [L]

请尽量不确定

© www.soinside.com 2019 - 2024. All rights reserved.