Url Rewriting Apache/Nginx

Had to learn about url rewrite engines for both **Apache **and **Nginx **to test a url rewrite for these servers

Needed something like this

http://server2:port/blah/zaps/#/pow?map=theMap

By inputting something like this

http://server/site/theMap

Apache config that works

<VirtualHost :80>
    ServerName example.com
    DocumentRoot /var/www/html/
    <Directory /var/www/html/>
        Allow From All
        RewriteEngine On
        RewriteRule ^site/(.)$ http://server2:port/blah/zaps/#/main?mapcfg=$1 [R=301,NE,L]
        RewriteRule ^site http://server2:port/blah/zaps [L]

Important - The flags specified on the url rewrite engine didn't work until the NE and R=301 were added NE = no escaping the special character of the # and the NE wouldn't work without the permanent redirect 301.

In Nginx

        location ^~/site {
                server_name_in_redirect off;
                port_in_redirect off;

                if ($arg_mapcfg = "") {
                  set $args $args&mapcfg=theMap;
                }

                rewrite ^(/SSA)$ /blah/zaps/mobile break;
                rewrite ^(/SSA/analyst.*)$ /blah/zaps$1 break;

                proxy_pass http://server2:port;
        }

I find the Nginx configuration easier to understand than the Apache.