[英]changing url 301 redirection with htaccess or php
example.com/a=process&b=5&b_id=5
how can I redirect this to 我该如何重定向到
example.com/a=process&b_id=5
So I can delete b=5 for all incoming url. 因此,我可以删除所有传入网址的b = 5。 But "a" , "b" and "b_id" changable not static.
但是“ a”,“ b”和“ b_id”可变不是静态的。 How can I do this?
我怎样才能做到这一点?
If you want to do internal redirection, use the following code: 如果要进行内部重定向,请使用以下代码:
RewriteEngine On
# The query variable b is comming first.
RewriteCond %{QUERY_STRING} ^b=[0-9]*&(.*)$
RewriteRule ^(.*)$ %2?%1 [L,NS]
# The query variable b is comming in middle.
RewriteCond %{QUERY_STRING} ^(.*)&b=[0-9]*&(.*)$
RewriteRule ^(.*)$ %3?%1&%2 [L,NS]
# The query variable b is comming last.
RewriteCond %{QUERY_STRING} ^(.*)&b=[0-9]*$
RewriteRule ^(.*)$ %2?%1 [L,NS]
Then just print the print_r($_GET);
然后只需打印
print_r($_GET);
The query variable b
won't be in the array. 查询变量
b
将不在数组中。
If you want to do external redirection, use the following code: 如果要进行外部重定向,请使用以下代码:
RewriteEngine On
# The query variable b is comming first.
RewriteCond %{QUERY_STRING} ^b=[0-9]*&(.*)$
RewriteRule ^.*$ %{REQUEST_URI}?%1 [R,L,NS]
# The query variable b is comming in middle.
RewriteCond %{QUERY_STRING} ^(.*)&b=[0-9]*&(.*)$
RewriteRule ^.*$ %{REQUEST_URI}?%1&%2 [R,L,NS]
# The query variable b is comming last.
RewriteCond %{QUERY_STRING} ^(.*)&b=[0-9]*$
RewriteRule ^.*$ %{REQUEST_URI}?%1 [R,L,NS]
Have a look at http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html to know about the R, L, NS, etc. 看看http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html了解R,L,NS等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.