#StackBounty: #php #configuration #apache2 #web-hosting #dns-hosting How to retain domain name in url – Configuring Virtual host in apa…

Bounty: 50

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

<Directory "/var/www/html/mydomain.com/">
DirectoryIndex index.php index.cgi index.html

<VirtualHost *:80>
ServerName mydomain.com
ServerAlias My Domain
ServerAdmin contact@mydomain.com
RewriteEngine on
DocumentRoot "/var/www/html/mydomain.com/"
LogLevel warn
ServerSignature Off

And enabled the site and restarted apache using the following commands

$ sudo a2ensite mydomain.com.conf
$ sudo service apache2 restart

Expected and Actual Behaviour

  1. www.mydomain.com should load http://ip/mydomain.com/index.php (Working Fine)
  2. Clicking on the internal link say contactus should redirect and url should be www.mydomain.com/contactus, but now it is http://myip/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.

Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.