Having an application running on port 10001 I would like to have a reverse proxy to serve it on hostname/ds . The only problem is that there are hard linked scripts to /scripts/...

That means hostname/ds/ shall get me to localhost:10001/ and hostname/scripts should first rewrite the request url to hostname/ds/scripts/*.

My configuration:

<VirtualHost *:80>
RewriteEngine on
RewriteRule /^scripts/(.*)$ /ds/scripts/$1 [L,PT]   

ProxyPass /ds/
ProxyPassReverse /ds/


It does not work: hostname/scripts/ gets a 404. while hostname/ds/scripts/ gets the right answer by the application.

According to https://stackoverflow.com/questions/9003358/apache-rewrite-then-proxy-pass PT should work. What am I doing wrong?

3 Answers 3


you have a typo in your pattern, try ^/ instead of /^ (latter will never match)


You can also do this by simply adding a second ProxyPass to match /scripts, like so:

<VirtualHost *:80>
    ProxyPass /scripts/
    ProxyPassReverse /scripts/

    ProxyPass /ds/
    ProxyPassReverse /ds/

I know this thread is already solved but it seems that you are trying to use ProxyPass to reach the web interface of a Synology DiskStation. For anyone who faced the same problem, with the latest version (DSM 5.1-5004 Update 2) I had to use the following config with the following RewriteRules:

<VirtualHost *:80>
    RewriteRule ^/scripts/(.*)$ /ds/scripts/$1 [L,PT]
    RewriteRule ^/webfm/(.*)$ /ds/webfm/$1 [L,PT]
    RewriteRule ^/webapi/(.*)$ /ds/webapi/$1 [L,PT]
    RewriteRule ^/webman/(.*)$ /ds/webman/$1 [L,PT]

    ProxyPreserveHost On
    ProxyRequests Off
    ProxyVia Off
    ProxyPass /ds/
    ProxyPassReverse /ds/

This obviously is subjected to change with newer versions of DS. I found using FireBug very helpful when searching for the folders that DS requests (that needed to be redirected).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.