Not detecting domain extension in pattern
4 posts
• Page 1 of 1
Not detecting domain extension in pattern
Hi,
I have a rule that works perfectly well on our site for all users, however for one of our larger members (a university) whom use a proxy domain to access our system, the rules fails..
Some large members like these are logged in automatically to our website by their IP address for students on their network or using their student portal. Hence the use of the proxy.
So typically the Url would be: http://subdomain1.sitename.com.au
The Rule is:
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3).sitename(.+)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
So ultimately the resulting uri passed to IIS is:
/au/page-subdomain1.aspx?subId=x
So when the University uses their proxy to initially access our site, rather than the url looking like this:
http://subdomain1.sitename.com.au
It looks like this:
http://subdomain1.sitename.com.au.ezp.lib.universityname.edu.au
They end up with a 404 and get
Requested Url: /page-subdomain1.aspx?subId=x
However IIS actually needs '/au/page-subdomain1.aspx?subId=x'
The problem as you can see is that the domain extension for the 3rd pattern %3 to get the /au/ part of the Uri to send to IIS fails.
mapfile_domains contains
.com.au au
.co.uk uk
.com us
.de de
.co.nz nz
.com.tw tw
.cn cn
I know I could add to the map file
.com.au.ezp.lib.universityname.edu.au au
However I would rather make it cleaner like this (fyi only .com.au needs to access this):
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3).sitename(\.com\.au)(.*)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
I would have expected (.*) on the end of the RewriteCond would have picked up '.ezp.lib.universityname.edu.au'
Can anyone see what I have missed or where I've gone wrong... I'm desperate for help.
Thanks heaps
Errol![Smile :)](./images/smilies/icon_e_smile.gif)
I have a rule that works perfectly well on our site for all users, however for one of our larger members (a university) whom use a proxy domain to access our system, the rules fails..
Some large members like these are logged in automatically to our website by their IP address for students on their network or using their student portal. Hence the use of the proxy.
So typically the Url would be: http://subdomain1.sitename.com.au
The Rule is:
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3).sitename(.+)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
So ultimately the resulting uri passed to IIS is:
/au/page-subdomain1.aspx?subId=x
So when the University uses their proxy to initially access our site, rather than the url looking like this:
http://subdomain1.sitename.com.au
It looks like this:
http://subdomain1.sitename.com.au.ezp.lib.universityname.edu.au
They end up with a 404 and get
Requested Url: /page-subdomain1.aspx?subId=x
However IIS actually needs '/au/page-subdomain1.aspx?subId=x'
The problem as you can see is that the domain extension for the 3rd pattern %3 to get the /au/ part of the Uri to send to IIS fails.
mapfile_domains contains
.com.au au
.co.uk uk
.com us
.de de
.co.nz nz
.com.tw tw
.cn cn
I know I could add to the map file
.com.au.ezp.lib.universityname.edu.au au
However I would rather make it cleaner like this (fyi only .com.au needs to access this):
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3).sitename(\.com\.au)(.*)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
I would have expected (.*) on the end of the RewriteCond would have picked up '.ezp.lib.universityname.edu.au'
Can anyone see what I have missed or where I've gone wrong... I'm desperate for help.
Thanks heaps
Errol
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: Not detecting domain extension in pattern
Hello,
I wonder why you are referring to %3 when it will match against (.*) and as far as I understand, you need to look for (\.com\.au) in mapfile_domains. Correct me if I'm wrong.
I suggest you to fix your rules like this:
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au) [NC]
RewriteRule ^$ /${mapfile_domains:%2}/page-%1.aspx?subId=${mapfile_subdomains:%1} [L]
I wonder why you are referring to %3 when it will match against (.*) and as far as I understand, you need to look for (\.com\.au) in mapfile_domains. Correct me if I'm wrong.
I suggest you to fix your rules like this:
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au) [NC]
RewriteRule ^$ /${mapfile_domains:%2}/page-%1.aspx?subId=${mapfile_subdomains:%1} [L]
Re: Not detecting domain extension in pattern
Hey Anton,
Thanks for this. However, my bad, thats not the problem..
I had actually removed an irrelevant part of the RewriteCond for the post (it was %3) however you are correct, the rule in my post should be %2 due to my alteration...
Looking at your suggestion:
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au) [NC]
RewriteRule ^$ /${mapfile_domains:%2}/page-%1.aspx?subId=${mapfile_subdomains:%1} [L]
The issue is still that the users proxy domain turns the url into
http://subdomain1.sitename.com.au(.ezp.lib.universityname.edu.au)
Here is the actual full rule from our site. I had previously removed the testServer stuff to simplify it for the post.
The rule is for use on both our UAT and Production servers:
# 'Rule updated to handle Eziproxy urls for IP Licences
RewriteCond %{HTTP_HOST} ^(testServer1\.|testServer2\.)*(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au)(.*)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
They end up with a 404 and get
Requested Url: /page-subdomain1.aspx?subId=x
Rather than '/au/page-subdomain1.aspx?subId=x'
Thanks again
Errol![Smile :)](./images/smilies/icon_e_smile.gif)
Thanks for this. However, my bad, thats not the problem..
I had actually removed an irrelevant part of the RewriteCond for the post (it was %3) however you are correct, the rule in my post should be %2 due to my alteration...
Looking at your suggestion:
RewriteCond %{HTTP_HOST} ^(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au) [NC]
RewriteRule ^$ /${mapfile_domains:%2}/page-%1.aspx?subId=${mapfile_subdomains:%1} [L]
The issue is still that the users proxy domain turns the url into
http://subdomain1.sitename.com.au(.ezp.lib.universityname.edu.au)
Here is the actual full rule from our site. I had previously removed the testServer stuff to simplify it for the post.
The rule is for use on both our UAT and Production servers:
# 'Rule updated to handle Eziproxy urls for IP Licences
RewriteCond %{HTTP_HOST} ^(testServer1\.|testServer2\.)*(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au)(.*)/? [NC]
RewriteRule ^$ /${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
They end up with a 404 and get
Requested Url: /page-subdomain1.aspx?subId=x
Rather than '/au/page-subdomain1.aspx?subId=x'
Thanks again
Errol
![Smile :)](./images/smilies/icon_e_smile.gif)
Re: Not detecting domain extension in pattern
Hello, Errol
Let's try it in a little different way:
# 'Rule updated to handle Eziproxy urls for IP Licences
RewriteCond %{HTTP_HOST} ^(testServer1\.|testServer2\.)*(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au) [NC]
RewriteProxy ^$ http://%2.sitename.com.au/${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
If it doesn't work please specify the initial requested URL and the desired resulting URL once again.
Let's try it in a little different way:
# 'Rule updated to handle Eziproxy urls for IP Licences
RewriteCond %{HTTP_HOST} ^(testServer1\.|testServer2\.)*(subdomain1|subdomain2|subdomain3)\.sitename(\.com\.au) [NC]
RewriteProxy ^$ http://%2.sitename.com.au/${mapfile_domains:%3}/page-%2.aspx?subId=${mapfile_subdomains:%2} [L]
If it doesn't work please specify the initial requested URL and the desired resulting URL once again.
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 11 guests