Score:0

Apache 2.4 : Redirect a subdomain to a new domain except one url the / (index.html)

cn flag

I just changed the domain name, and i would redirect the following links :

  • All old urls from subdomain.example.com/url.html --> subdomain.newdomain.com/url.html

Except one url (the /) (implies index.html) but not specied by user in the browser :

  • The domain itself subdomain.example.com ---> subdomain.newdomain.com/newpage.html

How can i do that please?

this is what i tried (without success, except mentionned links) :

       ServerName subdomain.example.com

       RewriteEngine on

      RewriteRule ^/(.*) https://%{subdomain.newdomain.com}/$1 [NC,R=301,L]

      RewriteCond "%{HTTP_HOST}"   "==subdomain.example.com"
      RewriteRule ^/ https://subdomain.newdomain.com/newpage.html [R=301,L]

       #<If "%{HTTP_HOST} == 'subdomain.example.com'">
       #        Redirect "/" "https://subdomain.newdomain.com/newpage.html"
       #</If>

Thank you

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.