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 [email protected]
 ServerName myservice.example.com
 RedirectPermanent / https://www.example.com/myservice
</VirtualHost>

<VirtualHost *.443>
 DocumentRoot /var/www/html
 ServerAdmin [email protected]
 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?

1
  • Clear your browser cache. Commented Jul 29, 2021 at 14:34

1 Answer 1

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>

1
  • thank you. Damn typos.
    – Najtim
    Commented Jul 29, 2021 at 14:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .