admin管理员组文章数量:1389968
What I wish to do
I have a number of Wordpress URLs I need to redirect, along with a 301 permanent redirect header being sent to browser.
The URLs to redirect are:
/?location=victoria
/?location=new-south-wales
/?location=queensland
/?location=south-australia
/?location=tasmania
/?location=northern-territory
Where to redirect to
I want to redirect them to the home page: /
I am not sure whether it's best to test for all six of those location=
strings, or to simply test for the one location=
string that is not to redirect.
The one that is not to redirect is ?location=western-australia
. E.g.,
/?location=western-australia
Additional considerations
Note that there are other /search-result/
URLs that have different variables in the query strings, such as ?weather=...
or ?water=...
. For example, /?location=victoria&weather=part-shade&water=&pasture=
AS seen in that example, it's also possible multiple variables will be in the query string, such as ?location=tasmania&weather=&water=moderate&pasture=
.
So I need to test for the presence of the above listed locations=
irrespective of whether or not it has other variables after it. The location=
variable will always be the first in the query string.
I am thinking it may be as simple as testing for /search-result/
AND victoria; tasmania; northern-territory; etc.
in the URL.
A different approach?
Would it make sense to do this using an .htaccess redirect, as opposed to having Wordpress do it? I am not sure of the advantages or disadvantages of each approach.
After posting this, and also seeing Admiral Noisy Bottom's comment, I've realised doing this with .htaccess
rewrite or redirect rules in going to be the most efficient approach. In the interest of upping my PHP and Wordpress specific PHP skills, I would still like to see how this could be achieved on that level. So I am leaving the question here. I've posted a modified version of this question on Stackoverflow asking how to do this with Redirect rules in htaccess.
本文标签: Redirect a list of URLs to another URLusing functionsphp
版权声明:本文标题:Redirect a list of URLs to another URL, using functions.php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744595696a2614762.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论