Index: kernel/classes/ezurlaliasml.php
===================================================================
--- kernel/classes/ezurlaliasml.php	(revision 21665)
+++ kernel/classes/ezurlaliasml.php	(working copy)
@@ -1378,8 +1378,9 @@
              $ini->variable( 'SiteAccessSettings', 'PathPrefix' ) != '' )
         {
             $prefix = $ini->variable( 'SiteAccessSettings', 'PathPrefix' );
+            $escapedPrefix = preg_quote( $prefix, '#' );
             // Only prepend the path prefix if it's not already the first element of the url.
-            if ( !preg_match( "#^$prefix(/.*)?$#", $uriString )  )
+            if ( !preg_match( "#^$escapedPrefix(/.*)?$#i", $uriString )  )
             {
                 $exclude = $ini->hasVariable( 'SiteAccessSettings', 'PathPrefixExclude' )
                            ? $ini->variable( 'SiteAccessSettings', 'PathPrefixExclude' )
@@ -1387,7 +1388,8 @@
                 $breakInternalURI = false;
                 foreach ( $exclude as $item )
                 {
-                    if ( preg_match( "#^$item(/.*)?$#", $uriString )  )
+                    $escapedItem = preg_quote( $item, '#' );
+                    if ( preg_match( "#^$escapedItem(/.*)?$#i", $uriString )  )
                     {
                         $breakInternalURI = true;
                         break;
@@ -1527,6 +1529,20 @@
                     $uriString = 'error/301';
                     $return = join( "/", $pathData );
                 }
+
+                if ( is_string( $return ) )
+                {
+                    if ( $ini->hasVariable( 'SiteAccessSettings', 'PathPrefix' ) &&
+                         $ini->variable( 'SiteAccessSettings', 'PathPrefix' ) != '' )
+                    {
+                        $prefix = $ini->variable( 'SiteAccessSettings', 'PathPrefix' );
+                        // Only remove the path prefix if it's the first element of the url.
+                        if ( strncmp( $return, $prefix . '/', strlen( $prefix ) + 1 ) == 0 )
+                        {
+                            $return = substr( $return, strlen( $prefix ) + 1 );
+                        }
+                    }
+                }
             }
             else
             {
