Redirect Aliasdomain, subdomains, other?

Discussion in 'General' started by zapyahoo, Dec 3, 2020.

  1. zapyahoo

    zapyahoo Member

    Could someone give me a hand with a permanent redirect before I do BÚBÚ?
    I have a website created many years ago that is a subdomain. This sub domain is created in my dns records and points to a dedicated client website (in website Domain field I have mysubdomain.domain.com). The main domain website is a totally different website and as nothing to do with this subdomain or redirect.

    So I bought a proper new domain for this website and already created the new domain dns.

    The questions is how to redirect and rewrite all subdomain.domain.com requests to www.newdomain.com. rewriting the url with 301 permanent moved and respecting links folders and file extensions. Example:
    Old link requested in a browser or cURL would be: subdomain.domain.com/teste/test123.php
    I would like ispconfig3 to do it's magic and rewrite the link to www.newdomain.com/teste/test123.php

    This is what I'm thinking... please correct me:
    1. Change the client website Domain field: mysubdomain.domain.com to newdomain.com
    2. In Sites > Aliasdomain:
    Domain: subdomain.domain.com
    Parent Website: select the newdomain.com website
    Redirect Type: R=301 L
    Would this work? or is there a better way.
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    1: that should work fine
    2: You can create it as aliasdomain, but should place this in the .htaccess of newexample.com:
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !oldexample.com$ [NC]
    RewriteRule ^(.*)$ http://www.newexample.com/$1 [L,R=301]
    So the pages are retained (this .htaccess is untested)
    Replace oldexample.com and newexample.com with the correct urls.
     
  3. zapyahoo

    zapyahoo Member

    Thanks Th0m. Will test and post back.
    Regarding SEO, the subdomain as a tracking code and a good analytics performance.
    I guess I will need a another analytics tracking code pointing to the new domain.
    Will the 301 be enough for google?
    In aliasdomain the SEO Redirect should be: no redirect?

    Yup, everything is working
    Code:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^oldsubdomain\.domain\.com$
    RewriteRule (.*)$ https://newdomain.com/$1 [R=301,L]
    
     
    Last edited: Dec 3, 2020
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Google will recognize the 301 and usually replace the results in some time. You can use their webmaster tools for some extra control.

    Thanks for posting back so other users know this works :)
     
  5. zapyahoo

    zapyahoo Member

    Let's Encrypt question. The new domain will require a new SSL and I was thinking about using free let's encrypt. I followed the debian 9 tutorial for Ispconfig installation and certbot is not mention there. checking the server:
    Code:
    sudo apt install python-certbot-apache
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      certbot python3-acme python3-augeas python3-certbot python3-certbot-apache python3-cffi-backend python3-chardet python3-configargparse python3-configobj python3-cryptography python3-idna python3-josepy
      python3-mock python3-openssl python3-parsedatetime python3-pbr python3-pyasn1 python3-requests python3-requests-toolbelt python3-rfc3339 python3-setuptools python3-six python3-tz python3-urllib3
      python3-zope.component python3-zope.event python3-zope.hookable python3-zope.interface
    Suggested packages:
      python3-certbot-nginx python-certbot-doc python-acme-doc python-certbot-apache-doc python-configobj-doc python-cryptography-doc python3-cryptography-vectors python-mock-doc python-openssl-doc
      python3-openssl-dbg doc-base python3-socks python-setuptools-doc
    Recommended packages:
      python3-pyicu
    The following NEW packages will be installed:
      certbot python-certbot-apache python3-acme python3-augeas python3-certbot python3-certbot-apache python3-cffi-backend python3-chardet python3-configargparse python3-configobj python3-cryptography
      python3-idna python3-josepy python3-mock python3-openssl python3-parsedatetime python3-pbr python3-pyasn1 python3-requests python3-requests-toolbelt python3-rfc3339 python3-setuptools python3-six python3-tz
      python3-urllib3 python3-zope.component python3-zope.event python3-zope.hookable python3-zope.interface
    0 upgraded, 29 newly installed, 0 to remove and 46 not upgraded.
    Need to get 1746 kB of archives.
    After this operation, 9334 kB of additional disk space will be used.
    Do you want to continue? [Y/n] n
    So I'm thinking if there's any issues installing it with Ispconfig 3.2.1?
    Under Sites > Websites I see the 2 options
    SSL:
    Let's Encrypt SSL:
    Don't really know the correct way of installing this and from the tutorials I have read people are generating and updating (cron) the SSL's via command line and in ispconfig they are only activating SSL: Yes and manually copying the certs into SSL tab.
     
  6. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    It is explained how to install in the tutorial on page 2: https://www.howtoforge.com/tutorial...dovecot-ispconfig-3-1/2/#-install-lets-encryp

    You should NOT install the package you mentioned
     
  7. zapyahoo

    zapyahoo Member

    Thanks I see. Not mentioned there but I guess the renewal is also handled by ispconfig cron?
     
  8. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Yes. And never use certbot from the CLI.
     
  9. zapyahoo

    zapyahoo Member

    Everything worked. Including the let's encrypt cert (saved 4 bucks year).
    If it helps anyone, the only thing I changed was:
    1. Change the client website Domain field: mysubdomain.domain.com to newdomain.com
    I actually created a new website for the new domain and renamed mysubdomain.domain.com to old-mysubdomain.domain.com, just in case I needed to revert fast.
     

Share This Page