htaccess 重写 URL 复杂问题


htaccess rewrite URL complex issue

http://my-domain.com/ppc-landing-page.php?Campaign=Boynton-Beach&AdGroup=Security%20System&Keyword=The%20Best%20Home%20Security%20System%20Company

我希望将其重写为

http://my-domain.com/Boynton-Beach/Boynton-Beach.php?Campaign=Boynton-Beach&AdGroup=Security%20System&Keyword=The%20Best%20Home%20Security%20System%20Company

并显示PPC登陆页面内的内容.php

这个想法是获取 Campaign 查询参数的值并将浏览器中的 url 重写为

http://my-domain.com/{$_GET['Campaign']}/{$_GET['Campaign']}.php?Campaign=Boynton-Beach&AdGroup=Security%20System&Keyword=The%20Best%20Home%20Security%20System%20Company

完整的查询字符串应该在那里

然后它应该将 ppc-landing-page 中的 $_GET 值替换为查询字符串中的值.php并显示内容。

在站点文档根目录的 .htaccess 中尝试以下RewriteRule

RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} campaign=([^&]+) [NC]
RewriteRule ppc-landing-page.php %1/%1.php [R=302,L]
RewriteCond %{REQUEST_URI} !^/ppc-landing-page.php
RewriteCond %{QUERY_STRING} campaign=([^&]+) [NC]
RewriteRule ^(.*)$ ppc-landing-page.php [L,QSA]
RewriteCond %{REQUEST_URI} ^/ppc-landing-page.php
RewriteCond %{QUERY_STRING} campaign=([^&]+) [NC]
RewriteRule ppc-landing-page.php %1/%1.php [R=302,L]

现在我放了这样的东西...首先它工作了,现在它不???