Check Domain
4 posts
• Page 1 of 1
Check Domain
Hi ALL,
I have a problem in redirect URL. Existing i already have some redirect rules for the website. But those rules are only for one domain only. Right now i have two websites with two domain : hk.xxx.com and usa.xxx.com. How can I check it with finding out the domain difference.
my redirect rules only can check the characters after the domain name
For example
RewriteRule ^findus.aspx(.*) /bookmark\-us/ [NC,L,R=301,O]
RewriteRule ^(bookmark\-us/?)(.*) /findus.aspx [NC]
I want to change it too
RewriteRule ^hk.xxx.com/findus.aspx(.*) /bookmark\-hk/
RewriteRule ^(bookmark\-hk/?)(.*) hk.xxx.com/findus.aspx
RewriteRule ^usa.xxx.com/findus.aspx(.*) /bookmark\-usa/
RewriteRule ^(bookmark\-usa/?)(.*) hk.xxx.com/findus.aspx
Thanks for help!
I have a problem in redirect URL. Existing i already have some redirect rules for the website. But those rules are only for one domain only. Right now i have two websites with two domain : hk.xxx.com and usa.xxx.com. How can I check it with finding out the domain difference.
my redirect rules only can check the characters after the domain name
For example
RewriteRule ^findus.aspx(.*) /bookmark\-us/ [NC,L,R=301,O]
RewriteRule ^(bookmark\-us/?)(.*) /findus.aspx [NC]
I want to change it too
RewriteRule ^hk.xxx.com/findus.aspx(.*) /bookmark\-hk/
RewriteRule ^(bookmark\-hk/?)(.*) hk.xxx.com/findus.aspx
RewriteRule ^usa.xxx.com/findus.aspx(.*) /bookmark\-usa/
RewriteRule ^(bookmark\-usa/?)(.*) hk.xxx.com/findus.aspx
Thanks for help!
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Check Domain
Hello,
To match a certain domain you need to use the following condition in front of a rule:
Regards
Andrew
To match a certain domain you need to use the following condition in front of a rule:
- Code: Select all
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
Regards
Andrew
Re: Check Domain
Hi.
Thanks for your reply.
After use the method you suggest, it works.
But i have one more question
If there are several rules that needs to follow the domain name, do i need to write this RewriteCond again according to how many rule i create.
That's
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-hk/ [NC,L,R=301,O]
RewriteRule ^aboutus.aspx(.*) /About\-hk/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^us\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-usa/ [NC,L,R=301,O]
RewriteRule ^aboutus.aspx(.*) /About\-usa/ [NC,L,R=301,O]
or
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-hk/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^aboutus.aspx(.*) /About\-hk/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^us\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-usa/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^aboutus.aspx(.*) /About\-usa/ [NC,L,R=301,O]
Thanks again.
Thanks for your reply.
After use the method you suggest, it works.
But i have one more question
If there are several rules that needs to follow the domain name, do i need to write this RewriteCond again according to how many rule i create.
That's
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-hk/ [NC,L,R=301,O]
RewriteRule ^aboutus.aspx(.*) /About\-hk/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^us\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-usa/ [NC,L,R=301,O]
RewriteRule ^aboutus.aspx(.*) /About\-usa/ [NC,L,R=301,O]
or
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-hk/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^aboutus.aspx(.*) /About\-hk/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^us\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-usa/ [NC,L,R=301,O]
RewriteCond %{HTTP:Host} ^hk\.xxx\.com$ [NC]
RewriteRule ^aboutus.aspx(.*) /About\-usa/ [NC,L,R=301,O]
Thanks again.
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Check Domain
hello,
The last one is correct. You use the condition with each rule. However, you may also try to use one of the dynamic rules, for example:
Regards
Andrew
The last one is correct. You use the condition with each rule. However, you may also try to use one of the dynamic rules, for example:
- Code: Select all
RewriteCond %{HTTP:Host} ^(hk|usa)\.xxx\.com$ [NC]
RewriteRule ^findus.aspx(.*) /bookmark\-%1/ [NC,L,R=301,O]
Regards
Andrew
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests