Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Placeholder wildcard for string in htaccess RewriteCond

I have the following RewriteCond in htaccess:

#RewriteCond %{HTTP_HOST} ^xyzdomain.com$

Now I would like to use a placeholder for the string "domain" in xyzdomain.com so that the condition matches with any domain like xyzhome.com, xyztravel.com, xyzshop.com, xyz*.com, etc.

Which placeholder can I use for the string?

like image 946
flip Avatar asked Aug 01 '13 07:08

flip


1 Answers

It's just a regex. You can do something like:

RewriteCond %{HTTP_HOST} ^xyz(.+)\.com$

The (.+) will match "any character one or more times".

Also note the \ escaping the . in .com. . is a special wildcard character with regular expressions so you have to escape it when you want to explicitly match ..

regular-expressions.info is a great place to learn more about how they work.

like image 173
Justin Warkentin Avatar answered Nov 22 '22 14:11

Justin Warkentin