Jump to content
Welcome to our new Citrix community!

Replace DNS hostname in URL

Recommended Posts

Hi all!


I have a public URL (https://subdomain.example.com/something/other) that I need to replace the hostname in to reach an internal host (https://another.example.com).

On the internal host there are multiple subpages (/internal1, /internal2/) that need to be available from the public URL


So I tried URL Transform:

set transform action rewrite1 -priority 10 -reqUrlFrom “subdomain.example.com/something/other/(.*)” -reqUrlInto “another.exexample.com/$1” -resUrlFrom “another.exexample.com/(.*)” -resUrlInto subdomain.example.com/something/other/$1


But this will just remove the /something/other/ part from the public URL so I get this (https://subdomain.example.com/internal1) in my public URL, and a subsequently a 404 error.


Does anyone know a ninja trick for solving this?



Ted Rasmussen

Link to comment
Share on other sites

You have to know what you wan the /something/other/<stuff> to map to in the /new pattern/<stuff>

IF the subdirectories pages on /something/other/page1.asp for example are mapping to a different page element, then you would need more explicit rules.


So, you might need some example of the public url vs private url to understand what mappings are needed and whether one regex alone will get the job done or if you need a series.


Example: (can be adusted for http:// or https:// or both)

If public URLs  map to internal urls (then a url transform can likely be implemented):

http://subdomain.example.com/something/other/                      -->  http://another.example.com/

http://subdomain.example.com/something/other/images/media.png  -->  http://another.example.com/images/media.png

http://subdomain.example.com/something/other/somepage.htm  -->  http://another.example.com/somepage.htm

http://subdomain.example.com/something/other/some.cgi?a1=b1&a2=b2 -->  http://another.example.com/some.cgi?a1=b1&a2=b2


Then the type of URL Transform you are using above will likely work. I'll review later to see if there are any issues with it.


If the internal pages aren't a direct mapping or need other modifications, then a better understanding of the patterns is needed and a different URL transform or a series of transforms may be required.  

Link to comment
Share on other sites

As a follow up, if instead your public mapping is something like:

http://subdomain.example.com/something/other/<stuff> --> http://another.example.com/<somethingelse>/<stuff>  as a single directory

and what you need is 

1) change the host name from public to internal


2) change the leading paths from /something/other to /<somethingelse>/<stuff>


But the rest of the path is fairly consistent, then we can do this with a modified URL transform. If the number of things you can map 2 is more variable then this, then we would need to know which patterns map to /internal1/<stuff> vs /internal2/<stuff>



Example 2: (can be adusted for http:// or https:// or both)

If public URLs  map to internal urls (then a url transform can likely be implemented):

http://subdomain.example.com/something/other/                      -->  http://another.example.com/somethingelse/

http://subdomain.example.com/something/other/images/media.png  -->  http://another.example.com/somethingelse/images/media.png

http://subdomain.example.com/something/other/somepage.htm  -->  http://another.example.com/somethingelse/somepage.htm

http://subdomain.example.com/something/other/some.cgi?a1=b1&a2=b2 -->  http://another.example.com/somethingelse/some.cgi?a1=b1&a2=b2


Note: I'm also including "/" in the trailing components, instead of leading...


Request URL From (public)             -->  Request URL Into (private)





Response URL From (private)           -->  Response URL Into (public)





The above variation, could be done with the above URL transform; if the directories for public to private mapping are a 1:1 mapping and the rest of the path is the same.

This may not be the requirement you describe, but will show you how to make adjustments to the Transform, in case this example is useful.


The more complex your scenario (or the more overlap you have) will affect whether multiple rules will be required with more specific (instead of less general) mappings.  And some requirements are hard to define because they aren't strictly mapped...which in a word is problematic.


If things coming to (client-side) /something/other/<stuff> could then map to different internal directories, such as some going to /internal1/<stuff> vs /internal2/<stuff>, then you would need to know which content maps to which subdirectory to be able to write the appropriate rules. 


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...