diff --git a/profile2_regpath.module b/profile2_regpath.module
index e26d7df..7d365e6 100755
--- a/profile2_regpath.module
+++ b/profile2_regpath.module
@@ -177,8 +177,8 @@ function profile2_regpath_form_alter(&$form, &$form_state, $form_id) {
       }
 
       // Grab first part of URL.
-      $path_parts = explode('/', $path);
-      $path_key = reset($path_parts);
+      $path_parts = explode('/', explode('/register', $path)[0]);
+      $path_key = end($path_parts);
 
       // Load profiles for this path key.
       $profile_types = profile2_regpath_regpath_load_multiple(array('path' => $path_key, 'status' => 1));
