Placeholder wildcard for string in htaccess RewriteCond

.htaccess, mod-rewrite

Solution

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.

Problem

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?

Original source