htaccess rewrite rule for specific domain

℡╲_俬逩灬. 提交于 2019-12-12 04:19:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!