0

I need to redirect myservice.example.com to www.example.com/myservice

My try so far: adding a new config to apache2, doing a2ensite and restarting apache2:

<VirtualHost *.80>
 DocumentRoot /var/www/html
 ServerAdmin administrator@example.com
 ServerName myservice.example.com
 RedirectPermanent / https://www.example.com/myservice
</VirtualHost>

<VirtualHost *.443>
 DocumentRoot /var/www/html
 ServerAdmin administrator@example.com
 ServerName myservice.example.com
 RedirectPermanent / https://www.example.com/myservice
</VirtualHost>

but when i enter myservice.example.com apache2 serves me www.example.com, not www.example.com/myservice

What am I missing?

Najtim
  • 1
  • 2

1 Answers1

0

Your redirect configuration is correct.

However, you need to replace the period between the IP and port in the VirtualHost directive with a colon.

e.g. <VirtualHost *:80> and <VirtualHost *:443>

slightly_toasted
  • 804
  • 5
  • 14