Apache Web Server - How do I make my index page point to one of the folders - apache

I have establish a web server on ubuntu.I have created some web sites on apache, each site has different folder.
In order to browse to my site website1 for example I need to type mymachine/Website1.
I want to type mymachine and it will redirect to the folder website1 , i.e. to my website.
Any suggestion, tried several settings.
Thanks

You have to it with Virtual hosts option,
first: you need to make specific folder in /var/www/..
second: point your folders with ServerName in Virtualhost file

Related

Configuration for two domains on the same server

I have two domains pointed to the same server.
olddomain.com is configured such that DocumentRoot is /var/www/html (Apache server) and finds all HTML and PHP files here. What is the simplest way to have newdomain.com find it's files (different from olddomain.com's) from a different folder (say /var/www/html2), such that when I type:
newdomain.com, it'll show a default index page
newdomain.com/foobar.htm it'll show newdomain.com/foobar.htm (including seeing this in the URL bar)
?
Create virtual hosts for each domain, very easy to do, Google it.

Domain for main document root gets pointed to newly enabled subdomain document root

I have a Ubuntu 16.04 which apache2 server is running. I have a website hosted in my primary domain which the document root is /var/www/html.
I use Webmin to create a subdomain and I have given the document root as /var/www/mysite.
when I restart the server and visit the main domain, it shows the website that I hosted in the /var/www/mysite, which is the subdomain document root.
If I remove or rename the conf file under /etc/apache2/sites-available/{created-subdomain.conf} file, the main domain again shows the website hosted in the /var/www/html document root.
What are the possible causes for this. I want my main domain to show the website I hosted in /var/www/html and subdomain to show the website I placed in /var/www/mysite
Sounds like you're not setting up ServerName domain.com in your configs, so Apache simply chooses the first one (alphabetically by Config file name) to serve.

htaccess multiple domains on one hosting using subdirectories

I've been trying to make the following thing work for hours, with no luck:
I have a vps hosting at digitalocean running ubuntu and xampp, and I have multiple domains pointing to the same ip address.
What I want to do is load files from different subdirectories for different domains.
So when I enter domain1.com into the browser, it loads the files from /htdocs/domain1/, and domain2.com from /htdocs/domain2/.
I've found several examples about this, but all of them had the same problem when I tried accessing subdirectories like this: domain1.com/test, they all redirected me to domain1.com/domain1/test, and I do not want to see the middle part domain1 in the url.
Is it even possible?
I've tried all the answers scattered around the internet searching for "multiple domains on one hosting htaccess", and "htaccess hide middle part of url".
Thank you for reading.
Assuming you're using apache as webserver:
define a VirtualHost for each domain, or host in domain. Give each VirtualHost as ServerName the host- or domain name you want to associate with it.
specify a different DocumentRoot for each VirtualHost. The DocumentRoot is the path to the actual files.
add the hostnames you want te be able to access the web files under to your DNS zone.
When done correctly, you will be able to access the web presence associated with each host- or domain name, without the need to enter any subdirectories in the URL, nor will their names show.

Mapping folder to different folder on the same Apache Server

I have My old domain on my server myexample.com with folder name "myexample" and a have different domain mymaindomain.com, What i am looking is whenever user opens mymaindomain.com/contest it opens the site that is in "myexample" folder and still keep the url in address bar mymaindomain.com/contest/whatever.xxx using htaccess or httpd on apache server.
Put
Alias /contest /public_html/myexample
in the virtual host definition for myexample.com. Note though, that this may cause links in your content to be wrong if they expect to be located at / instead of at /contest.

WAMP Server directing me to internet locations when I click on the folders in www folder

I installed WAMP Server on my laptop, which is running Windows 8 Pro.
I created a number of folders in the www folder in the wamp folder. My problem is that whenever I try accessing the folders from the localhost page in my web browser, I am taken to the internet page of the folder i.e. I have two folders named family & prestashop. Whenever I click on them, a tab opens in my browser directing me to http://family/ instead of http://localhost/family/
What could be the problem?
Without seeing your httpd.conf (or httpd-vhosts.conf) it is hard to say where your problem is (or why it is a problem). Usually, to set up multiple sites, you will add virtual hosts to your httpd.conf or httpd-vhosts.conf which will tell WAMP what to do when people try to access that folder. The difference between a web address that looks like http://localhost/family and http://family is probably that you have set up a virtual host which allows you to get at that directory without running through 'localhost'.
Do you have something like this in your http-vhosts.conf in C:\wamp\bin\apache\Apache<version>\conf\extras\ ?
<VirtualHost *:80>
DocumentRoot "C:\wamp/www/family/"
ServerName "family"
</VirtualHost>