0

I have a problem with the rewriterule on my openlitespeed server. Within the home page of my page(wordpress): domainweb.com I have a button that when clicked takes me to a test that is in another web application with the following domain: domainapp.com/test/any_thing. I want that when clicking on said "test" button it takes me to the application but that it continues to keep me domainweb.com/test/any_thing

#HTACCESS FINAL
RewriteEngine On
RewriteRule ^/test/(.*)$ https://dominioapp.com/test/$1/ [L]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

I want to know what is wrong with my htaccess

Adriaan
  • 17,741
  • 7
  • 42
  • 75
jango
  • 1
  • 1
  • Welcome to Stack Overflow! [Posts on Stack Overflow have to be in English](/help/non-english-questions). Bilingual content is not allowed either. If you feel more comfortable writing in Spanish, feel free to try our sister site [es.so]. – Adriaan May 04 '23 at 13:03

1 Answers1

0

This is not possible by means of rewriting alone. Reason is that rewriting only works internally . You'd need proxy module for this, which obviously means that the proxy module has to be installed and enabled.

First options directly using the proxy module:

ProxyPass /test/ https://app.example.com/test/
ProxyPassReverse /test/ https://app.example.com/test/

Second option using the proxy module embedded in the rewrite module:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)\.web\.example\.com$
RewriteRule ^/?test/(.*)/?$ https://app.example.com/test/$1/ [P]

(The RewriteCond is only required if both hosts are served from the same location, so if those rules are processed for both requests.)


However you need to keep in mind that you have a penalty for such a setup: two full http roundtrips for each request initiated by the client. That means longer load time and additional load on the server side.

Here is the documentation of the proxy module, that documentation should always be the first place to start: https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

[Disclaimer: I have not tested above lines but just written them down. I hope there is no typo.]

arkascha
  • 41,620
  • 7
  • 58
  • 90