问题
So I have this rule that's working perfectly:
RewriteRule ^images_designs/([^.]+)-d00([^/]+)\.png$ /image_design_watermark.php?design=$2 [L,QSA,NC]
Now I would just add an additional "language" variable related to the domain the htaccess is used on
I have tried this but it's not working:
RewriteCond %{HTTP_HOST} ^(ni-dieu-ni-maitre|blablabla)\.com$ [NC]
RewriteRule images_designs/([^.]+)-d00([^/]+)\.png$ /image_design_watermark.php?design=$2&language=fr [L,QSA,NC]
RewriteCond %{HTTP_HOST} ^(no-gods-no-masters|ni-dios-ni-amo)\.com$ [NC]
RewriteRule images_designs/([^.]+)-d00([^/]+)\.png$ /image_design_watermark.php?design=$2&language=en [L,QSA,NC]
回答1:
The %{HTTP_HOST}
includes subdomains so you should add the www
into that.
RewriteCond %{HTTP_HOST} ^(?:www\.)?(ni-dieu-ni-maitre|blablabla)\.com$ [NC]
and
RewriteCond %{HTTP_HOST} ^(?:www\.)?(no-gods-no-masters|ni-dios-ni-amo)\.com$ [NC]
or you could make it looser and take off the starting anchor, ^
I'd go this route though.
Reference: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html
来源:https://stackoverflow.com/questions/35260186/htaccess-rewrite-rule-for-specific-domain