Let's say I'm using a pan-resolved domain name of *.domain.com
Now I want to judge when the domain name is not www.domain.com and satisfies the condition for ([\w]{2,5}). Domain.com's two-level domain name is redirected to www.domain.com/domain.php?domain= ([\w]{ 2,5}) of the rewrite rule.
The first thing I wrote was this:
Set $domain ", if ($hots ~* ([\w]{2,5}). \domain\.com) { set $domain $;} if ($domain!~" www ") { rewrite ^ $domain \.domain\.com (. *) $ http://www.domain.com$1?domain= $domain last;}
Then the error is \w for the unsafe match.
And then I changed to:
Set $domain ", if ($hots ~*" ([\w]{2,5}). \domain\.com ") {Set $domain $ A, } if ($domain! =" www ") { rewrite ^ $doma In\.domain\.com (. *) $ http://www.domain.com$1?domain= $domain &query_string redirect;}
This time does not have the error, but cannot jump correctly.
So ask me where this code problem is, how should I rewrite it?
Reply to discussion (solution)
Then the error is \w for the unsafe match.
Rewrite [0-9a-za-z] to try this?
In addition, the resolution of the two-level domain name can be added to the PHP portal for more flexible functions.
Change to [0-9a-za-z] is also the same, because before he suggested \w unsafe I changed to this, but also invalid, and then added double quotation marks after the no problem, but the condition seems to judge not satisfied