diff --git a/lib/AccountManager/App.pm b/lib/AccountManager/App.pm
index fc4f01919c27e622e941ec24a32aa42cc31bb9db..182e1108343be8bfc5685f8b7c5fd8478755a0b3 100644
--- a/lib/AccountManager/App.pm
+++ b/lib/AccountManager/App.pm
@@ -266,9 +266,6 @@ sub req_select_sp {
     $self->respond(
         template => 'select_sp.tt2.html',
         data     => {
-            env => {
-                SCRIPT_NAME => $ENV{SCRIPT_NAME}
-            },
             metadata   => $metadata->parse(type => 'sp'),
             federation => $federation,
         }
diff --git a/templates/web/complete_challenge.tt2.html b/templates/web/complete_challenge.tt2.html
index 5ed0e323634df45e757ea4c20dde608d6e59b479..a8a165d60e4c6c938ba231f02b1276a04fe66192 100644
--- a/templates/web/complete_challenge.tt2.html
+++ b/templates/web/complete_challenge.tt2.html
@@ -15,7 +15,7 @@
             [% lh.maketext("An email challenge including a validation token has been emailed to you at [_1].", email) %]
             [% lh.maketext("Please copy and paste the validation token in the form below to proof that you are administrator of this service.") %]
         </p>
-        <form action="[% env.SCRIPT_NAME %]" method="get">
+        <form action="[% app.url %]" method="get">
             <label for="token">[% lh.maketext("Please provide the validation token here:") %]</label>
             <input name="token" value="" id="token" type="text" class="required error"/>
             <input type="hidden" name="entityid" value="[% entityid %]"/>
diff --git a/templates/web/select_email.tt2.html b/templates/web/select_email.tt2.html
index 9b14a95140d8fc307bbdf3fe3659f4c11a0acc34..d391ad1f371dd3a0db468e77553ce4a1d22ad5d6 100644
--- a/templates/web/select_email.tt2.html
+++ b/templates/web/select_email.tt2.html
@@ -14,7 +14,7 @@
         <p>[% lh.maketext("Before you can create test accounts at this Identity Provider, we need to ensure you are a legitimate administrator of '[_1]'.", sp.displayname) %]</p>
 
     [% IF sp.contacts.defined %]
-        <form action="[% env.SCRIPT_NAME %]" method="get">
+        <form action="[% app.url %]" method="get">
             <p>[% lh.maketext("Select the email address where an email challenge can be sent to validate your identity:") %]</p>
         [% FOREACH email IN sp.contacts.sort %]
             <input id="[% email %]" name="email" value="[% email %]" type="radio" class="required"/>
diff --git a/templates/web/select_federation.tt2.html b/templates/web/select_federation.tt2.html
index 1983f9edf7c53bd7902898f2a15520016b655ff4..acf97836b683b02c84eb7263ae176eb8b7fd5628 100644
--- a/templates/web/select_federation.tt2.html
+++ b/templates/web/select_federation.tt2.html
@@ -12,7 +12,7 @@
     <div class="content clearfix">
         <h2>[% lh.maketext("Select your federation") %]</h2>
 
-        <form action="[% env.SCRIPT_NAME %]" method="get">
+        <form action="[% app.url %]" method="get">
             <p>[% lh.maketext("Select the federation corresponding to the service you want to test::") %]</p>
         [% FOREACH federation IN federations.sort %]
             <input id="[% federation %]" name="federation" value="[% federation %]" type="radio" class="required"/>
diff --git a/templates/web/select_sp.tt2.html b/templates/web/select_sp.tt2.html
index e47b596fcc2f21381d22fd77c267b9f8fd6a1bc4..4962f79ebe57c68900d652094b268a57ccbe1159 100644
--- a/templates/web/select_sp.tt2.html
+++ b/templates/web/select_sp.tt2.html
@@ -16,7 +16,7 @@
             [% lh.maketext("You must be an administrator of that service to continue afterwards.") %]
         </p>
 
-        <form action="[% env.SCRIPT_NAME %]" method="get">
+        <form action="[% app.url %]" method="get">
             <label for="entityid">[% lh.maketext("Type the name or entityID of service to test:") %]</label>
             <br/>
             <select id="entityid" name="entityid" class="required">