Score:0

How to make redirect rewrite rule for https subdomain on apache (CentOS8)?

ps flag

I have own domain for example.

https://example.com

Below is my apache virtual host with 301 redirect rewrite rule.

<VirtualHost *:80> 
 ServerName example.com 
 DocumentRoot /var/www/html/example/public 
 <Directory /var/www/html/example> 
   AllowOverride All 
 </Directory> 
RewriteEngine On 
RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R=301,L] 
</VirtualHost>

I can only access https://example.com but not for https://subdomain.example.com. The 'Not Secure' alert. Any advice or guidance on this would be greatly appreciated, Thanks.

in flag
You need a certificate for subdomain.example.com. This has nothing to do with the redirect.
joenpc npcsolution avatar
ps flag
Dear Gerald Schneider, Thanks. btw, could you pls advise how to add subdomain in virtual host? Do I need another virtual host separate from main domain.
in flag
If you have the certificate for the subdomain in a separate file or it should deliver other content than the main domain then you need another VirtualHost for it. Otherwise you can just add it as an alias to the existing VirtualHost.
joenpc npcsolution avatar
ps flag
Dear Gerald Schneider, Thank you very much. I'll try it out.
I sit in a Tesla and translated this thread with Ai:

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.