Tag Archive for rewriting

Zend Router simple extension through simple regex

/**
* Add this in your bootstrap
*/
protected function _initRoutes() {
    
            $ctrl = Zend_Controller_Front::getInstance();
            $router = $ctrl->getRouter();
            //match every call on <a href="http://ZEND_ROOT/aZ2s-Ty9" >http://ZEND_ROOT/aZ2s-Ty9</a>
            $route = new Zend_Controller_Router_Route_Regex('([a-zA-Z0-9]+-[a-zA-Z0-9]+)',
                array(
                    //dispatch this to the VController
                    'controller' => 'v',
                    // iAction()
                    'action'     => 'i'
                    ),
                array(
                    //send the captured value has the "e" parameters of the request
                    1 => 'e'
                    )
            );
    
            //give a name to your route and add it to the default router
            $router->addRoute('view',$route);
        }

source

HAProxy URL Rewriting

frontend webserver
bind    :80
mode    http
acl is_www hdr_beg(host) -i     <a href="http://www.domain.com" >www.domain.com</a>
use_backend http_cluster if is_www
default_backend http_redir

backend http_redir
mode    http
balance source
option  nolinger
server  web 127.0.0.1:8080 redir <a href="http://www.domain.com" >http://www.domain.com</a>

backend http_cluster
mode    http
option  forwardfor
balance source
option  httpclose
option  httpchk HEAD / HTTP/1.0
server  web01 172.16.0.11:80 weight 1 check inter 1000 rise 5 fall 1
server  web02 172.16.0.12:80 weight 1 check inter 1000 rise 5 fall 1
server  web03 172.16.0.13:80 weight 1 check inter 1000 rise 5 fall 1
server  web04 172.16.0.14:80 weight 1 check inter 1000 rise 5 fall 1

source

URLRewriter.NET Regex

<rewriter>

<!-- EXCEPT FOR PREDEFINED DIRECTORIES -->

<rewrite url="~/(.+)/((js|img|css|op|mtn)/(.+))" to="~/$2" processing="stop"></rewrite>

<!-- EXCEPT FOR COMMONLY IMPORTED FILES -->

<rewrite url="^(/.+(.gif|.png|.jpg|.ico|.pdf|.css|.swf|.zip|.js)(?.+)?)$" to="$1" processing="stop" />

<!-- ALL URL WILL BE REWRITTEN  -->

<rewrite url="~/(.+)/(.+).aspx(?(.+))?$" to="~/$2.aspx?site=$1&amp;$4" processing="stop"></rewrite>

</rewriter>

source