0

I have a Linux server that runs my website, the URL looks like this:

mysite.com/SymbolicLink/

I had to create a SymbolicLink because of the file structure that looks like this:

/var/www/html/MyWebsite/Code/web/

So the SymbolicLink points to the web folder inside my folder structure. That is where my index.php file is.

How can I avoid all this SymLink business and just type mysite.com without having it display my file structure on the browser?


Using Apache 2.4.7

1 Answer 1

1

If you are using Apache for the web server software, you can use DocumentRoot /var/www/html/MyWebsite/Code/web in a VirtualHosts section of the the Apache configuration file, /etc/httpd/conf/httpd.conf, to point to that folder as the root of your website.

E.g., you could include something like the following at the bottom of httpd.conf:

<VirtualHost *:80>
    ServerName mysite.com
    ServerAlias www.mysite.com
    ServerAdmin [email protected]
    DocumentRoot /var/www/html/MyWebsite/Code/web
    ErrorLog /var/www/html/MyWebsite/logs/error.log
    CustomLog /var/www/html/MyWebsite/logs/transfer.log common
</VirtualHost>

If you are unfamiliar with the VirtualHost section, you can have multiple websites on one web server using VirtualHost sections in the httpd.conf file. The DocumentRoot directive specifies the directory to be used for the top-level, i.e., "root", for the website for mysite.com. You can also specify where individual error and transfer logs for this particular website should be located (create the "logs" directory first, if it doesn't exist). And you can specify a contact email address, which can be anything you like, for ServerAdmin. Using ServerAlias www.mysite.com allows either mysite.com or www.mysite.com to work, provided you have DNS configured to point www.mysite.com as well as mysite.com to the IP address of your server. After making changes to the httpd.conf file, restart Apache.

Additional information on using virutal hosts with Apache can be found at Apache Virtual Host documentation.

2
  • Yes, I am using Apache. Could you explain how I would do this in a bit more detail? My Apache version is 2.4.7.
    – J_Strauton
    Aug 17, 2015 at 21:19
  • @J_Strauton, I added some additional details.
    – moonpoint
    Aug 17, 2015 at 23:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .