I am moving hosts and the URL structure will change as the new site (same domain name) will be done the Wordpress.

I have many URL's where the first part of the page name is the same and they all need to be redirected to a single page on the new site. For example.

  • http://www.example.com/binfet-timeinthepark.htm
  • http://www.example.com/binfet-backtothecity.htm
  • http://www.example.com/binfet-justmeetmehalfway.htm

all need to go to:


Is there a way to write a rule to capture all of these? There are about 50 different cases ie. In this example "binfet" is at the beginning but are about 50 different names.


In response to @Fayaz

I have about 50 cases where the URL's begin with the same name but then have different endings. For each case all URL's for that case go to a single new page.


http://www.example.com/xyz-sometext.htm http://www.example.com/xyz-someothertext.htm ... all go to a single new URL


  • 1
    OK, does the new URL have any pattern with the old group of URLs? For example, if http://www.example.com/xyz-sometext.htm redirects to http://www.example.com/xyz-new, can I say from it that http://www.example.com/abc-someothertext.htm will redirect to http://www.example.com/abc-new? The reason I'm asking is because if there is a pattern then your rewrite will be small, otherwise you'll have to write 50 RewriteRule, one for each group.
    – Fayaz
    Feb 6, 2017 at 11:58

2 Answers 2



I suggest you use the full URL in RewriteRule.

So for all the URLs that start with binfet to go to /bev-binfet/, you need to add the following directive in your .htaccess file (before other Rewrite Rules):

RewriteRule ^binfet http://www.example.com/bev-binfet/ [R=301,L]


Most likely you have other rules that redirect non-www links to www links. So in that case using the full URL will avoid additional redirects. For example, someone tries to access:


Without the full URL in RewriteRule it'll first redirect to:


and then, finally:


With the solution mentioned here, you'll avoid the first redirect & go directly to:


Further Query:

For some reason, I feel like there is more to your question. You said:

There are about 50 different cases ie. In this example "binfet" is at the beginning but are about 50 different names.

A. Did you mean there are 50 URLs where the URL starts with a particular phrase (for example binfet)?


B. Did you mean there are 50 such starting phrases (like one group of URLs starting with binfet, another group of URLs starting with xyz etc.) and each group ends up in a unique url?

If A is the case then the solution given here is enough. However, if B is the case, then either you'll have to write this rule 50 times for each starting phrase or you'll have to find a better pattern that can cover all of them.

Please update your question with more details if B is the case.


In this example "binfet" is at the beginning but are about 50 different names.

To redirect all URLs that start binfet then try the following mod_rewrite directive before your existing WP directives in your .htaccess file:

RewriteRule ^binfet /bev-binfet/ [R=301,L]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.