我正在努力处理这个 .htaccess URL 重写..?
I am struggling with this .htaccess URL rewrite..?
我有访问 WordPress 网站的流量 https://www.example.com/?edd-listener=IPN
我正在尝试重写它以便它实际加载 https://www.example.com/paypal-ipn-handler.php
我试过了,但它只是加载 WP 主页而不是我的 paypal-ipn-handler。
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteRule /?edd-listener=IPN /paypal-ipn-handler.php [L,NC]
</IfModule>
我不知道我需要做什么调整..??
任何关于我在这里做错的反馈都将不胜感激。谢谢!
您需要匹配一个查询字符串,但 RewriteRule
只匹配 URI。在 RewriteEngine On
行下方插入此规则:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)edd-listener=IPN(&|$) [NC]
RewriteRule ^ /paypal-ipn-handler.php? [L,NC]
# remaining rewrite rules below this line
请注意,这不会在浏览器中更改 URL。如果您需要使用:
RewriteCond %{QUERY_STRING} (^|&)edd-listener=IPN(&|$) [NC]
RewriteRule ^ /paypal-ipn-handler.php? [L,NC,R=302]
我有访问 WordPress 网站的流量 https://www.example.com/?edd-listener=IPN
我正在尝试重写它以便它实际加载 https://www.example.com/paypal-ipn-handler.php
我试过了,但它只是加载 WP 主页而不是我的 paypal-ipn-handler。
RewriteEngine On
<IfModule mod_rewrite.c>
RewriteRule /?edd-listener=IPN /paypal-ipn-handler.php [L,NC]
</IfModule>
我不知道我需要做什么调整..??
任何关于我在这里做错的反馈都将不胜感激。谢谢!
您需要匹配一个查询字符串,但 RewriteRule
只匹配 URI。在 RewriteEngine On
行下方插入此规则:
RewriteEngine On
RewriteCond %{QUERY_STRING} (^|&)edd-listener=IPN(&|$) [NC]
RewriteRule ^ /paypal-ipn-handler.php? [L,NC]
# remaining rewrite rules below this line
请注意,这不会在浏览器中更改 URL。如果您需要使用:
RewriteCond %{QUERY_STRING} (^|&)edd-listener=IPN(&|$) [NC]
RewriteRule ^ /paypal-ipn-handler.php? [L,NC,R=302]