Sam
Sam

Reputation: 15518

How to rewrite 3 slichtly varying domain names into 1 REGEX line?

Given are three website domains each with .net and .org domains: only difference is that one domain ends with a single letter i one with double letters ie and one with single letter y all directly after the letter R

www.XYZARi.com
www.XYZARie.com
www.XYZARy.com

The below rules work fine. But is there a faster way for apache to rewrite these rules? making them go into one line? If one Apache line is faster than the below three, how do I achieve that?? Thanks!

RewriteCond %{HTTP_HOST} ^www\.xyzari\.(net|org)$ [OR]
RewriteCond %{HTTP_HOST} ^www\.xyzarie\.(net|org)$ [OR]
RewriteCond %{HTTP_HOST} ^www\.xyzary\.(net|org)$
RewriteRule ^$ /index.htm [L]

Upvotes: 0

Views: 100

Answers (2)

Oussama Jilal
Oussama Jilal

Reputation: 7739

Try this :

RewriteCond %{HTTP_HOST} ^www\.xyzar(ie?|y)\.(net|org)$
RewriteRule ^$ /index.htm [L]

Upvotes: 3

Jon Lin
Jon Lin

Reputation: 143946

Try:

RewriteCond %{HTTP_HOST} ^www\.XYZAR[iy]e?\.com$

or

RewriteCond %{HTTP_HOST} ^www\.XYZAR(i|ie|y)\.com$

The first is shorter, but could also match XYZARye

Upvotes: 2

Related Questions