URL redirection in Apache2

Trying to redirect url from one web server on my local network to another web server on my local network. I assumed that all I needed was a .htaccess file in the / var / www directory, the contents of which are only 3 lines:

Options + FollowSymLinks

RewriteEngine on

RewriteMatch newsite \ .level2 \ .level1 \ .com http://192.168.0.250:8080

Also I created a symbolic link in the / etc / apache 2 / mods-enabled folder for / etc / apache2 / mods-available / rewrite.load

1st: When I enter "newsite.level2.level1.com" in the browser, I end up at level2.level1.com. 2nd: Does RewriteMatch add ports to the new url.

It should be mentioned that level2.level1.com via DynDns.org as I have Comcast and the feature allowing * .level2.level1.com is enabled

Thanks for watching Rich

+1


source to share


2 answers


Rewriting rules are applied to the portion of the URL path, not the main portion. You control the bulk of compliance by placing rewrite rules in appropriate containers <VirtualHost>

.

You can redirect to another host, but the rule you have will never match.



If you want to redirect all requests, try something like

  RewriteEngine On
  RewriteMatch .* http://192.168.0.250:8080/

      

+1


source


You can use mod_proxy for this:



ProxyPass / http://192.168.0.250:8080/
ProxyPassReverse / http://192.168.0.250:8080/

      

0


source







All Articles