3

I would like to redirect some folder within apache2.

My webserver uses with plesk 11.

I followed this tutorial. It says I've got to put redirection rules in this file /etc/apache2/sites-available/default. For my webserver this file doesn't even exist. I guess that's because of plesk's website management. However there is only this one file: 000-default. I did not modify it!

I also managed to locate the config file for my domain. Which is located here

/var/www/vhosts/example.org/conf/last_httpd.include

I want to solve my problem with Apache 2 "ProxyPass". Because I think that's the easiest way to solve the redirect.

As I found out, I have to add this line

ProxyPass /folder/map/ http://www.google.de

This does not work. It exits with error "403 forbidden". Please give me a hint. Thank you!

2
  • I really don't see in the given config anything about how to open example.org/mc/map URL. It handles /mc/map/up, /mc/map/standalone and /mc/map/tiles, but not /mc/map.Probably you need to remove temporarily this config and check example.org/mc/map again
    – Sergey L
    Feb 20, 2013 at 4:31
  • @SergeyL You are right. I checked this. I think their tutorial is just wrong. So I edited my post.
    – Peter
    Feb 24, 2013 at 16:39

3 Answers 3

7

Plesk 10/11:

1. Create your individual config for apache2

cd /var/www/vhosts/example.org
sudo touch conf/vhost.conf
sudo vim 

2. Insert your directives there

Press I and insert those lines

RewriteEngine On
ProxyPass /directory/subdir/ http://localhost:8123/
ProxyPassReverse /directory/subdir/ http://localhost:8123/

Press Esc followed by : and write: wq and press

3. Tell apache to use the config

sudo /usr/local/psa/admin/bin/httpdmng --reconfigure-all
sudo service apache2 restart

4. You are done.


Plesk 12

  • Login as administrator
  • Select subscription
  • Open in control panel
  • Web server settings
  • Additional directives for HTTP && Additional directives for HTTPS:


RewriteEngine On
ProxyPass /directory/subdir/ http://localhost:8123/
ProxyPassReverse /directory/subdir/ http://localhost:8123/


Sources:
oli.new-lan.de
forum.parallels.com

1
  • For me this resulted in an 404 error when accessing http://example.org/directory/subdir (without the trailing /) in a browser. To fix it, I created an empty directory /var/www/vhosts/example.org/directory/subdir/. Jun 25, 2020 at 16:48
1

The answer above is correct, but I have smth to add:

ProxyPass /directory/subdir/ http://localhost:8123/
ProxyPassReverse /directory/subdir/ http://localhost:8123/

No need to add RewriteEngine On here.

/usr/local/psa/admin/bin/httpdmng --reconfigure-domain <YOUR_DOMAIN>

No need to restart httpd also.

1
  • Welcome to Super User! This is really a comment and not an answer to the original question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient reputation you will be able to comment on any post.
    – DavidPostill
    Jul 5, 2015 at 7:08
0
ProxyPass /directory/subdir/ http://localhost:8123/
ProxyPassReverse /directory/subdir/ http://localhost:8123/

is right but I had to activate proxy_http module first. By checkbox in Plesk or by terminal.

sudo a2enmod proxy_http
service apache2 reload

otherwise I've got errors like this in my log:

No protocol handler was valid for the URL /myapp. 
If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.
1
  • The hint to activate/install proxy_http. If you don't have it, you get the mentioned error. Sep 12, 2017 at 11:37

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.