diff --git a/.gitattributes b/.gitattributes
index 13399d35c2fd3092979b4cd6c79c98a2c959c7d7..599065d397ae26c96124635f7202cc2315dbe7b3 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2663,6 +2663,7 @@ library/ZendAfi/Controller/Plugin/SelectionBib.php -text
 library/ZendAfi/Controller/Plugin/SetupLocale.php -text
 library/ZendAfi/Controller/Plugin/System.php -text
 library/ZendAfi/Controller/Plugin/XHProfile.php -text
+library/ZendAfi/Controller/Router/RewriteWithoutBaseUrl.php -text
 library/ZendAfi/Feed.php -text
 library/ZendAfi/Filters/Post.php -text
 library/ZendAfi/Filters/ReadSql.php -text
diff --git a/library/ZendAfi/Controller/Router/RewriteWithoutBaseUrl.php b/library/ZendAfi/Controller/Router/RewriteWithoutBaseUrl.php
new file mode 100644
index 0000000000000000000000000000000000000000..f2d898d441abea030b8858b7aa8142d37b9aaab5
--- /dev/null
+++ b/library/ZendAfi/Controller/Router/RewriteWithoutBaseUrl.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
+ *
+ * AFI-OPAC 2.0 is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
+ * the Free Software Foundation.
+ *
+ * There are special exceptions to the terms and conditions of the AGPL as it
+ * is applied to this software (see README file).
+ *
+ * AFI-OPAC 2.0 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
+ *
+ * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
+ * along with AFI-OPAC 2.0; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA 
+ */
+
+class ZendAfi_Controller_Router_RewriteWithoutBaseUrl extends Zend_Controller_Router_Rewrite {
+    /**
+     * Generates a URL path that can be used in URL creation, redirection, etc.
+     * 
+     * @param  array $userParams Options passed by a user used to override parameters
+     * @param  mixed $name The name of a Route to use
+     * @param  bool $reset Whether to reset to the route defaults ignoring URL params
+     * @param  bool $encode Tells to encode URL parts on output
+     * @throws Zend_Controller_Router_Exception
+     * @return string Resulting absolute URL path
+     */ 
+    public function assemble($userParams, $name = null, $reset = false, $encode = true) {
+        if ($name == null) {
+            try {
+                $name = $this->getCurrentRouteName();
+            } catch (Zend_Controller_Router_Exception $e) {
+                $name = 'default';
+            }
+        }
+        
+        $route = $this->getRoute($name);
+        $url   = $route->assemble($userParams, $reset, $encode);
+
+        if (!preg_match('|^[a-z]+://|', $url)) {
+					$url = '/'. $url;
+        }
+
+        return $url;
+    }
+}
+
+?>
\ No newline at end of file
diff --git a/library/startup.php b/library/startup.php
index a70c428cc1428d2a40a9fc4c6b10680e5829a3e6..bdef801b2c4afc2908677156920c3d5e57ca3392 100644
--- a/library/startup.php
+++ b/library/startup.php
@@ -41,7 +41,7 @@ function setupOpac() {
 	setupCache($cfg);
 	setupMail($cfg);
 
-	$front_controller = setupFrontController();
+	$front_controller = setupFrontController($cfg);
 	return $front_controller;
 }
 
@@ -265,7 +265,7 @@ function setupMail($cfg) {
 }
 
 
-function setupFrontController() {
+function setupFrontController($cfg) {
 	$front_controller = Zend_Controller_Front::getInstance()
 		->addModuleDirectory(MODULEDIRECTORY)
 		->addControllerDirectory(ROOT_PATH.'afi/application/modules/opacpriv/controllers','opacpriv')	
@@ -282,7 +282,7 @@ function setupFrontController() {
 		->setParam('useDefaultControllerAlways', true);
 
 
-	setupRoutes($front_controller);
+	setupRoutes($front_controller, $cfg);
 
 	if (!Class_Users::isCurrentUserSuperAdmin())
 		return $front_controller;
@@ -303,7 +303,10 @@ function setupFrontController() {
 }
 
 
-function setupRoutes($front_controller) {
+function setupRoutes($front_controller, $cfg) {
+	if ('1' == $cfg->get('enable_rewriting'))
+		$front_controller->setRouter(new ZendAfi_Controller_Router_RewriteWithoutBaseUrl());
+
 	$front_controller
 		->getRouter()
 		->addRoute('embed',