Index: kernel/classes/ezcontentobjecttreenode.php
===================================================================
--- kernel/classes/ezcontentobjecttreenode.php	(revision 21679)
+++ kernel/classes/ezcontentobjecttreenode.php	(working copy)
@@ -5825,7 +5825,7 @@
                 $pathIdenStr = substr( $prepend, strlen( $prepend ) -1 ) == '/'
                                 ? $path . '/'
                                 : $path;
-                if ( strncmp( $pathIdenStr, $prepend, strlen( $prepend ) ) == 0 )
+                if ( strncasecmp( $pathIdenStr, $prepend, strlen( $prepend ) ) == 0 )
                     $cleanURL = eZURLAliasML::cleanURL( substr( $path, strlen( $prepend ) ) );
                 else
                     $cleanURL = eZURLAliasML::cleanURL( $path );
Index: kernel/classes/ezurlaliasml.php
===================================================================
--- kernel/classes/ezurlaliasml.php	(revision 21679)
+++ kernel/classes/ezurlaliasml.php	(working copy)
@@ -1374,12 +1374,16 @@
         $originalURIString = $uriString;
 
         $ini = eZIni::instance();
-        if ( $ini->hasVariable( 'SiteAccessSettings', 'PathPrefix' ) &&
-             $ini->variable( 'SiteAccessSettings', 'PathPrefix' ) != '' )
+
+        $prefixAdded = false;
+        $prefix = $ini->hasVariable( 'SiteAccessSettings', 'PathPrefix' ) &&
+                      $ini->variable( 'SiteAccessSettings', 'PathPrefix' ) != '' ? eZURLAliasML::cleanURL( $ini->variable( 'SiteAccessSettings', 'PathPrefix' ) ) : false;
+
+        if ( $prefix )
         {
-            $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 +1391,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;
@@ -1395,7 +1400,10 @@
                 }
 
                 if ( !$breakInternalURI )
-                    $internalURIString = eZURLAliasML::cleanURL( eZURLAliasML::cleanURL( $prefix ) . '/' . $uriString );
+                {
+                    $internalURIString = $prefix . '/' . $uriString;
+                    $prefixAdded = true;
+                }
             }
         }
 
@@ -1474,8 +1482,24 @@
                 }
                 $lastID = $link;
             }
-            if ( strcmp( join( "/", $verifiedPath ), $internalURIString ) != 0 ) // Check for case difference
-                $doRedirect = true;
+
+            if ( !$doRedirect )
+            {
+                $verifiedPathString = implode( '/', $verifiedPath );
+                // Check for case difference
+                if ( $prefixAdded )
+                {
+                    if ( strcmp( $originalURIString, substr( $verifiedPathString, strlen( $prefix ) + 1 ) ) != 0 )
+                    {
+                        $doRedirect = true;
+                    }
+                }
+                else if ( strcmp( $verifiedPathString, $internalURIString ) != 0 )
+                {
+                    $doRedirect = true;
+                }
+            }
+
             if ( preg_match( "#^module:(.+)$#", $action, $matches ) )
             {
                 $uriString = 'error/301';
@@ -1527,6 +1551,15 @@
                     $uriString = 'error/301';
                     $return = join( "/", $pathData );
                 }
+
+                // Remove prefix of redirect uri if needed
+                if ( $prefix && is_string( $return ) )
+                {
+                    if ( strncasecmp( $return, $prefix . '/', strlen( $prefix ) + 1 ) == 0 )
+                    {
+                        $return = substr( $return, strlen( $prefix ) + 1 );
+                    }
+                }
             }
             else
             {
