简体   繁体   English

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

I want this to be rewritten as 我希望将其重写为

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

and display the content inside ppc-landing-page.php 并在ppc-landing-page.php中显示内容

The idea is to get the value of Campaign query parameter and rewrite the url in the browser to 这个想法是获取Campaign查询参数的值,然后在浏览器中将网址重写为

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

the full query string should be there 完整的查询字符串应该在那里

and then it should replace the $_GET values in the ppc-landing-page.php with the values in the query string and display the content. 然后应将ppc-landing-page.php中的$ _GET值替换为查询字符串中的值,并显示内容。

Try the following RewriteRule in the .htaccess of your site's document root 在您网站的文档根目录的.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]

Now I have put something like this...First it worked now it's not ??? 现在我放了这样的东西...首先它现在起作用了而不是???

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM