title: Setting global variable to rewrite some url - .htacess
body: <p>Perhaps it will appear quite easy but I have an issue with my .htaccess. I want to rewrite my url such that <code>&lt;a href="/admin"&gt;some text&lt;/a&gt;</code> can be rewritten as <code>&lt;a href=""http://localhost:8888/madison/the-madison-project/admin/index"&gt;some text&lt;/a&gt;</code></p>
  
  <p>So I set this : </p>
  
  <pre><code>SetEnv root:/madison/the-madison-project/
  RewriteRule ^admin[/]?$ {%ENV:root}admin/index
  </code></pre>
  
  <p>But it doesn't work. </p>
  
  <p>How can I fix it?</p>
  
  <p>Edit : after several attempts, it is perhaps simpler I post my whole .htaccess file </p>
  
  <pre><code>RewriteEngine On
  ExpiresActive On
  
  #Expire Header
  &lt;FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)$"&gt;
  ExpiresDefault "now plus 7 days"
  &lt;/FilesMatch&gt;
  
  ExpiresByType text/css "now plus 7 days"
  ExpiresByType text/html "now plus 7 days"
  ExpiresDefault "now plus 7 days"
  
  AddOutputFilterByType DEFLATE text/plain text/html text/xml text/css
  
  SetEnv root:/madison/the-madison-project/
  #SetEnvIf Request_URI ^ root=/madison/the-madison-project/
  #RewriteRule ^ - [E=root:/madison/the-madison-project/]
  
  RewriteRule ^(assets|inc) - [L]
  
  RewriteRule ^admin[/]?$                         %{ENV:root}admin/index
  
  RewriteRule ^admin/edit/(.*)$                   %{ENV:root}index.php?type=admin&amp;action=edit&amp;page=$1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^admin/(.*)$                        %{ENV:root}index.php?type=admin&amp;action=view&amp;page=$1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^login$                             index.php?action=view&amp;type=login&amp;%1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^forgot-password$                   index.php?action=view&amp;type=forgot-password&amp;%1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^edit/user(/)?$                     index.php?action=edit&amp;type=user&amp;%1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^signup(/)?$                        index.php?action=edit&amp;type=user&amp;id=0&amp;%1  [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^user/([0-9]+)(/)?                  index.php?action=view&amp;type=note&amp;user=$1&amp;%1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^(suggestion|comment)/([0-9]+)(/)?  index.php?action=view&amp;type=note&amp;page=open&amp;note_type=$1&amp;note=$2&amp;%1 [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^([0-9A-Za-z\-_]+)/(suggestion|comment)/([0-9]+)(/)?    index.php?action=view&amp;type=note&amp;page=$1&amp;note_type=$2&amp;note=$3&amp;%1 [L]
  
  #Catch All Pages
  RewriteRule ^index\.php$ - [L]
  
  RewriteCond %{QUERY_STRING} ^(.*)?$
  RewriteRule ^([0-9A-Za-z\-_]+)(/)?          %{ENV:root}index.php?action=view&amp;type=page&amp;page=$1&amp;%1 [L]
  </code></pre>