URL is prepending www. before the URL dev.contoso.com

I have an Ubuntu server running Apache2 for my website.  I need to create a dev copy of the site so my web developer can make changes and test.  So far this is what I did.

  1. Cloned the VM server
  2. Changed the IP
  3. Created a new DNS record for the server (dev.contoso.com)
  4. The original url was www.contoso.com and I want to create a new Virtual Host.
  5. Copied both the contoso.com.conf in the Sites-Enabled and Sites-Available directory with the name dev.contoso.com.conf
  6. Restarted the Apache2 service successfully

With all this completed I entered the URL dev.contoso.com in both IE and Chrome and the address is rewritten to https://www.dev.contoso.com 
I looked at the dev.contoso.com.conf and all ReWrites are remarked out.

        ServerName flhlaw.com
        ServerAlias www.flhlaw.com
        Redirect / http://dev.contoso.com
        ServerName contoso.com
        ServerAlias dev.contoso.com
        Redirect /secure  https://dev.contoso.com
    ServerAdmin webmaster@localhost
    ServerName dev.contoso.com
    ServerAlias dev.contoso.com
    DocumentRoot /var/www/www.contoso.com/web
   SSLEngine on
   SSLCertificateFile /etc/apache2/cert/contoso.crt
   SSLCertificateKeyFile /etc/apache2/cert/contoso.key
   SSLCertificateChainFile /etc/apache2/cert/gd_bundle-g2-g1.crt
        Options FollowSymLinks
        AllowOverride All
    <DIRECTORY /var/www/www.contoso.com/web>
        Options +FollowSymLinks
        AllowOverride All
        #AuthType Basic
        #AuthName "Restricted Content"
        #AuthUserFile /etc/apache2/.htpasswd
        #Require valid-user

        # <IfModule mod_rewrite.c>
        # RewriteEngine On
        # RewriteBase /
        # RewriteCond %{REQUEST_FILENAME} -f [OR]
        # RewriteCond %{REQUEST_FILENAME} -d
        # RewriteRule ^.*$ - [S=40]
        # RewriteRule (.*)/(.*)/$ /index.php?page=$1&id=$2 [QSA,L]
        # RewriteRule (.*)/$ /index.php?page=$1 [QSA,L]
        # </IfModule>
        # php_value auto_prepend_file /var/www/www.contoso.com/prepend.php
    ErrorLog ${APACHE_LOG_DIR}/www.contoso.com_error.log
    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn
    CustomLog ${APACHE_LOG_DIR}/dev.contoso.com_access.log combined

Open in new window

LVL 27
yo_beeDirector of Information TechnologyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
First problem to fix - dev.contoso.com fails to resolve in DNS, so no way to do any debugging.

Fix this first + retest.

If dev.contoso.com fails to resolve + somehow the contoso.com IP returns, then likely you're falling through to your Apache default config.

Fix your resolution first, as you're just guessing otherwise.

You'll know your resolution is fixed when this works...

imac> dig +short dev.contoso.com a
# returns an IP, rather than nothing

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yo_beeDirector of Information TechnologyAuthor Commented:
So my DNS settings on the network interface was incorrect.  I changed it to my internal DNS server and I was able to resolve http but not https

Sorry for my ignorance, but I am pretty much a notice with Apache and Linux
yo_beeDirector of Information TechnologyAuthor Commented:
So it turned out that the DNS was an issue, but there seems to be something else that prepends www to the url.  If I create a new VH with www.contoso.test it works.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.