php - Ubuntu Server Virtual Host not redirecting properly


Question: 

I have installed Web site on my Ubuntu Server.

The following things are installed on my Server for running web service. 1) Apache2 2) PHP5 3) MySql

My main website is redirected to https.

Example (changed for security purpose)

    <VirtualHost *.80>
ServerName www.example.com
ServerAlias example.com
Redirect permanent / https://www.example.com
</VirtualHost>

In my default-ssl.conf file i have added the following info.

<VirtualHost _default_:443>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
SSLEngine On
SSLCertificateFile /etc/ssl/example.com/sslcertificate.pem
SSLCertificateKeyFile /etc/ssl/example.com/sslcertificate.key
</VirtualHost>

Other settings in above is default.

My main issues comes when i create link for my website like www.example.com it goes to Apache2 Default Web Page and does not go to correct site. If i write in browser directly it works perfect and redirects to https://www.example.com




1 Answer: 

try to enable your virtual host by command a2ensite default-ssl.conf and disable the default 00-default.conf with command a2dissite 00-defaullt.conf

 

More Articles


linux - diff command to get number of different lines only

Can I use the diff command to find out if two of files differ by k lines?I don't want the contextual difference, just the total number of lines that are different between two files. Best if the result is just a single integer.

bash - append text to file using shell from php

I trying to append passed text as parameter to file using shell scriptthis is the code of shell echo $1>>/etc/freeradius/mods-enabled/ldapthis shell will get the text to add it to the file ldap in /etc/freeradius/mods-enabled path , I call this shell in this format # sh /etc/append.sh hello

ubuntu - Shell command to get remote system's ip address from its mac address?

I have the HWAddress of remote machine but its IP address is not static and keeps changing. How do I get its IP address through shell?Relevant questions mostly have the remote system in the same network, but in my case its not.EDIT: I know its IP range.


Get Python command line output when called from a bash script

This may be a super simple question. I am calling a Python script on an Lubuntu OS (Cubietruck) via a shell script. This is to automate the process on start up (I want to maintain this process). Is there a simple way to view the output from Python? At the moment the Python script runs in the backgro

shell - Gmail imap can't access folders with space (or other escapted characters) in the title

Lets say i'm connection to imap.gmail.com via shell>> openssl s_client -connect imap.gmail.com:993 -crlf>> a1 login asdasd@gmail.com asdasdasdasdGetting the list of the folders:>> a1 list "" *Respond:....* LIST (\HasChildren) "/" "github"* LIST (\HasNoChildren) "/" "Wizz&AKA-Ai

shell - Move output of Find command unix

Im learning unix programming , i want to find all files whose size is greater than 1M an print them into a file.here is my code find. -size +1M -print0 | xargs -I -O '{}' mv '{}' files all sites i have found refer to this one as right one , but it does not work . currently im working on ubuntu


node.js - Not able to run my node app at port 80 on ubuntu 16.04

I want to run my node app at port 80 in ubuntu 16.04. But the moment I'm trying to run my app with npm start its throwing error Port in already in use whereas it's not in use. According to Github Reply, We need root privileges to run on ports below 1048 which is correct.So the moment I'm trying to r

ruby on rails - tmux: are my other terminals still running?

I have started using a certain technique for launching my web code since I switched server setups. I type tmuxsudo startserverrailsCtrl+B then DThen to reboot I type tmuxsudo killall rubysudo startserverrailsCtrl+B then DMy questions are: when I kill the ruby, does that end the session that I starte

php - How to redirect everything after slash to domain before?

This is what I'm trying to do:I want example.com/car/{whatever} redirected to example.com/{whatever}. For example, example.com/car/honda should be redirected to example.com/hondaBUT if there is nothing after /car/, then just leave it as that. How can i do that in .htaccess ?

node.js - Querying multiple sensors regularly using NodeJS

I need to fetch the values of about 200 sensors every 15 seconds or so. To fetch the values I simply need to make an HTTP call with basic authentication and parse the response. The catch is that these sensors might be on slow connection so I need to wait at least 5 seconds for one sensor (but usuall