using proxy instead of redirection with htaccess rewriteRule

15,774

Have a look at these links / options:

  1. [P] flag:

  2. mod_proxy (possibly -- but I think #1 should be enough if it's on the same server):

Share:
15,774
zanona
Author by

zanona

My primary focus over the past 15 years has been full-stack web development and implementation, experimenting with technologies while thinking openly about how tech and users can interact. Currently, acting as a web consultant for goal-oriented businesses and concentrating on designing interactive systems, UX research/ implementation and engineering/development of elaborate online platforms.

Updated on June 28, 2022

Comments

  • zanona
    zanona almost 2 years

    I'm developing a webapp and for the static files I'm simply using apache at localhost while the backend is on a couchdb instance running at localhost:5984.

    The webapp interacts with files from the backend all the time. So what is happening when trying to test on apache all file requests to localhost:5984 are getting blocked due the cross-domain policy so the only way to get that working is starting the browser by setting flags to ignore that.

    But again I get stuck when trying to test the app on mobile such ipad or iphone.

    Currently I have this on my .htaccess file.

    RewriteEngine  on
    
    # these are 302 http redirections instead of serving as a proxy
    RewriteRule auth http://localhost:5984/auth [L]
    RewriteRule db/([\s\S]+) http://localhost:5984/db/$1 [L]
    RewriteRule send/([\s\S]+) http://localhost:5984/send/$1 [L]
    
    # these are just redirections to static files and work great
    RewriteRule ^([a-z/.]+) _attachments/$1 [L]
    RewriteRule ^$ _attachments/ [L]
    

    As you can see I have really no idea on how to deal with apache configuration unfortunately. But what is happening right now is that for some of these rules apache is simply redirecting the page instead of provide it as a proxy server which causes the issue with cross-domain.

    Also on the first auth rule I send POST and DELETE requests which as a redirection instead of proxy it won't pass the data being POSTed through.

    So what I would like to achieve is to activate some kind of feature (if it exists) which will make apache simply render the page as it was on the localhost domain instead of redirect it. (I named this a a proxy, but perhaps that's not even the right term, sorry for any mistake committed with the nomenclatures).

    Is is possible to achieve such action? Thanks in advance