特定域的htaccess重写规则 [英] htaccess rewrite rule for specific domain

查看:70
本文介绍了特定域的htaccess重写规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一条很好的规则:

So I have this rule that's working perfectly:

RewriteRule ^images_designs/([^.]+)-d00([^/]+)\.png$ /image_design_watermark.php?design=$2 [L,QSA,NC]

现在,我将添加一个与htaccess使用的域相关的附加语言"变量

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]

推荐答案

%{HTTP_HOST}包含子域,因此您应该在其中添加www.

The %{HTTP_HOST} includes subdomains so you should add the www into that.

RewriteCond %{HTTP_HOST} ^(?:www\.)?(ni-dieu-ni-maitre|blablabla)\.com$ [NC]

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.

参考: http://httpd.apache.org/docs/2.0/misc/rewriteguide.html

这篇关于特定域的htaccess重写规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆