I'm trying to configure virtual host in apache2 in ubuntu instance hosted with aws and successfully redirected the requests to the appropriate website.
Further clicking on the links on the index page changes the url in the browser to ip/mydomain.com/uri where i expect it to be mydomain.com/uri.
Here are the things i've done
- Purchased mydomain.com from GoDaddy
- Edited A record to ip (public ip of the aws instance)
- Hosted ubuntu instance with aws and installed apache2,php,mysql
- Created a site with wordpress and installed on the aws instance
- Configured Virtual Host Entries under /etc/apache2/sites-enabled/mydomain.com.conf
Configuration:
<Directory "/var/www/html/mydomain.com/">
DirectoryIndex index.php index.cgi index.html
</Directory>
<VirtualHost *:80>
ServerName mydomain.com
ServerAlias My Domain
ServerAdmin contact@mydomain.com
SetEnv VAR_IF_YOU_NEED_ONE VALUE
RewriteEngine on
DocumentRoot "/var/www/html/mydomain.com/"
LogLevel warn
ServerSignature Off
</VirtualHost>
And enabled the site and restarted apache using the following commands
$ sudo a2ensite mydomain.com.conf
$ sudo service apache2 restart
Expected and Actual Behaviour
- www.mydomain.com should load http://ip/mydomain.com/index.php (working fine)
- Clicking on the internal link say contactus should redirect and url should be www.mydomain.com/contactus, but now it is http://ip/mydomain.com/contactus
Thanks for any references and support on this.
Note: I'm pretty new to this area so incase you feel this question is not clear kindly suggest improvements on comment before downvoting. That will help me improve this.