Score:0

apache2 redirect from subleveldomain to URL

tr flag

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?

Michael Hampton avatar
cz flag
Clear your browser cache.
Score:0
bd flag

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>

Najtim avatar
tr flag
thank you. Damn typos.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.