Search code examples
tomcatlocalhosttomcat7virtualhostfiddler

Running localhost webapp projects under domain name using fiddler2


I have a Tomcat server running on my local dev machine(running Windows8) & I use fiddler2 to assign an alias to localhost as my domain name (www.mydomainName.com), so my application webpages open in the browser like this:

 http://www.mydomainName.com/myAppName/welcome.html

instead of

 http://localhost:8080/myAppName/welcome.html

But I want to my webapp pages urls to omit 'myAppName' & be something like :

http://www.mydomainName.com/welcome.html

How could I configure to do this ?


Solution

  • How exactly did you assign an alias to localhost as my domain name (www.mydomainName.com?

    The simplest way to do what you want to do is to use FiddlerScript.

    Inside Rules > Customize Rules > OnBeforeRequest, you'd write the following code:

    if (oSession.fullUrl.HostnameIs("www.mydomainname.com"))
    {
        // WARNING: REPLACE IS CASE-SENSITIVE!
        oSession.fullUrl = oSession.fullUrl.Replace("//www.mydomainname.com/myAppName/", "//localhost:8080/);
    }