| 
 
 
 | 
| Keep Server Online 
 If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
 
 or
 
 
   
 A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
 
 Thank You! Steffen
 
 Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
 |  | 
 | 
| | 
| | 
|  Topic: RewriteMap problems |  |  
| Author |  |  
| gordonchow 
 
 
 Joined: 14 Aug 2015
 Posts: 1
 Location: Hong Kong
 
 | 
|  Posted: Mon 17 Aug '15 8:10    Post subject: RewriteMap problems |   |  
| 
 |  
| How can i use RewriteMap and work with Alias (not affect the alias redirection) on Virtual Host? I hv no idea.
 
 
  	  | Code: |  	  | <VirtualHost *:80>
 DocumentRoot /var/www/html
 ServerName resource.centos6-gordon.japan
 ErrorLog logs/error_log_192
 CustomLog logs/access_log_192 common
 
 RewriteEngine on
 Rewritelog /var/log/httpd/rewirte_log
 Rewriteloglevel 9
 
 RewriteMap redirectmap "txt:/etc/httpd/conf/mapredirect"
 RewriteRule     "^/~?([^/]+)(/?|.*)$"   ${redirectmap:$1|%{REQUEST_URI}} [PT]
 
 Alias /ming        /home/Gordon/Ming
 Alias /dora        /home/Gordon/Dora
 
 </VirtualHost>
 
 | 
 
 
 rewirte_log
 
  	  | Code: |  	  | RewriteRule     "^/~?([^/]+)(/?|.*)$"   ${redirectmap:$1|%{REQUEST_URI}} [PT] 
 (2) rewrite '/gordon' -> 'http://hk.yahoo.com'
 (2) implicitly forcing redirect (rc=302) with http://hk.yahoo.com
 (2) forcing 'http://hk.yahoo.com' to get passed through to next API URI-to-filename handler
 
 
 
 RewriteRule     "^/~?([^/]+)(/?|.*)$"   ${redirectmap:$1|%{REQUEST_URI}}
 
 (2) implicitly forcing redirect (rc=302) with http://google.com
 (1) escaping http://google.com for redirect
 (1) redirect to http://google.com [REDIRECT/302]
 
 
 | 
 |  |  
| Back to top |  |  
| James Blond Moderator
 
  
 Joined: 19 Jan 2006
 Posts: 7442
 Location: EU, Germany, Next to Hamburg
 
 | 
|  Posted: Tue 15 Sep '15 17:26    Post subject: |   |  
| 
 |  
| You need a rewrite rule before the other rule to exclude the aliases 
 like
 
  	  | Code: |  	  | RewriteRule ^/(ming|dora) - [L]
 RewriteMap redirectmap "txt:/etc/httpd/conf/mapredirect"
 RewriteRule     "^/~?([^/]+)(/?|.*)$"   ${redirectmap:$1|%{REQUEST_URI}} [PT]
 
 | 
 |  |  
| Back to top |  |  
 
 | 
 |  | 
 |  |