【问题标题】:I am struggling with this .htaccess URL rewrite..?我正在为这个 .htaccess URL 重写而苦苦挣扎..?
【发布时间】:2021-04-17 06:25:03
【问题描述】:

我在https://www.example.com/?edd-listener=IPN 的 WordPress 网站上有流量

我正在尝试重写它以便实际加载 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>

我不知道我需要做出什么调整..??

对于我在这里做错的任何反馈,我们将不胜感激。谢谢!

【问题讨论】:

    标签: apache .htaccess mod-rewrite url-rewriting


    【解决方案1】:

    您需要匹配查询字符串,但 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]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-22
      • 1970-01-01
      相关资源
      最近更新 更多