# Rewrite/Redirect URL

**URL:** <https://discourse.haproxy.org/t/rewrite-redirect-url/5289>\
**Category:** Help!\
**Created:** [May 28, 2020, 8:05pm UTC](https://discourse.haproxy.org/t/rewrite-redirect-url/5289 "2020-05-28T20:05:46Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![GerhardZA](https://avatars.discourse-cdn.com/v4/letter/g/e0b2c6/32.png) [@GerhardZA](https://discourse.haproxy.org/u/GerhardZA)\
**Post date:** [May 28, 2020, 8:05pm UTC](https://discourse.haproxy.org/t/rewrite-redirect-url/5289/1 "2020-05-28T20:05:46Z")

</div>

Hello everyone,

I have searched the web but can’t figure it out.

I’m running hapee-2.0

I need to rewrite/redirect an URL to a new path:  
**[http://oldservice.domain.com/otrs/customer.pl](http://oldservice.domain.com/otrs/customer.pl)** must be rewritten/redirected to **[https://newservice.domain.com](https://newservice.domain.com)**

I have done the https and the [oldservice.domain.com](http://oldservice.domain.com) to [newservice.domain.com](http://newservice.domain.com) redirect

The problem I have is that it still adds the last part of the URL in the new URL like this:  
**[https://newservice.domain.com/otrs/customer.pl](https://newservice.domain.com/otrs/customer.pl)**  
I need the **/otrs/customer.pl** part to be completely removed

Config:  
frontend:  
redirect scheme https if { hdr(Host) -i [newservice.domain.com](http://newservice.domain.com)} !{ ssl\_fc }  
redirect prefix [https://newservice.domain.com](https://newservice.domain.com) code 301 if { hdr(host) -i [oldservice.domain.com](http://oldservice.domain.com)}

backend:  
http-request set-path %[path,regsub(^/otrs/?,/)]

Any nudge in the right direction will be highly appreciated

Thanks  
G
