logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: RewriteMap problems
Author
gordonchow



Joined: 14 Aug 2015
Posts: 1
Location: Hong Kong

PostPosted: Mon 17 Aug '15 8:10    Post subject: RewriteMap problems Reply with quote

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: 7373
Location: Germany, Next to Hamburg

PostPosted: Tue 15 Sep '15 17:26    Post subject: Reply with quote

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


Reply to topic   Topic: RewriteMap problems View previous topic :: View next topic
Post new topic   Forum Index -> Apache