Apache - Browsing of any domain URL is pointing to same folder - php

We have hosted multiple PHP websites in different domains in same server. Each domain have it own folder under /var/www/html. For e.g.
example1.com is pointing to /var/www/html/example1.com
example2.com is pointing to /var/www/html/example2.com
example3.com is pointing to /var/www/html/example3.com
etc..
Since Saturday, when I browse example1.com or example2.com or example3.com, it is showing same content in browser. That means every time I browse it is showing website content from /var/www/html/example3.com folder. I'm not sure how this change happened. May be one of our ex-employees changed this.
So I checked httpd.conf file in /etc/httpd/conf. Here documentroot is set correctly for all the domains. As I'm new to web administration, I'm not sure where exactly I've to correct to make all websites point to right folder.
What exactly is this problem? How will I rectify this?
Do I need to correct this in http.conf file or .htaccess file in every domain folders?
I'm struggling since yesterday. Any help is really appreciated.
Thanks in advance..

Finally I'm able to resolve the issue. I have about four websites with different domains running in this server. For couple of websites, under VirtualHost tag, DocumentRoot and ServerName were missing. After I added those values and restarted the apache server, it started working.
The incorrect entry was looking like this:
<VirtualHost *:80>
ServerAdmin demo#demo.com
ServerAlias www.example1.com
</VirtualHost>
I changed that as mentioned below:
<VirtualHost *:80>
ServerAdmin demo#demo.com
ServerName example1.com
ServerAlias www.example1.com
DocumentRoot /var/www/html/example1.com/
</VirtualHost>
Thank you all for the help.

Related

Why does Laravel website runs on two different paths with the same route on the live server

I uploaded the laravel project on the live server. When I try the url with :
www.abcd.com.au/admin/dashboard
then it shows me a messed up site and also shows some contents that were downloaded from bootstrap template website .
And when I try this url:
www.abcd.com.au/project/public/admin/dashboard
then it shows me the correct website and neatly as the way website was designed on the localhost xampp and on the live server.
I wanted to have the url as: /admin/dashboard and not project/public/admin/dashboard
How can i set up this on the live server please?
Thanks.
It sounds like your URL is pointed to the wrong folder. In Laravel the URL must point to the project's public folder.
open your VirtualHost on your server .conf file and update DocumentRoot and try
<VirtualHost *:80>
DocumentRoot "/Path your project/project/public"
ServerName www.abcd.com.au
<Directory "/Path your project/project/public">
Options All
AllowOverride All
Allow from all
</Directory>
</VirtualHost>

How to point to project index page by default in XAMPP

i am pretty new this kind of work. I had developed a web app using PHP. i am using XAMPP Server. Now when i am hitting http://www.mywebsite.com/myproject i got my project index page. Now what i looking is if i enter http://www.mywebsite.com it should display myproject's index page.
I am not sure what is this term called. I didn't know how to search for this solution.
Your help will be much appreciated if you can provide the term i should look for or the solution for this.
thanks
When you edit the httpd-vhosts.conf file (which is in C:\xampp\apache\conf\extra), edit the DocumentRoot property accordingly.
Your current settings are probably looking like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName www.mywebsite.com
</VirtualHost>
which directs you to the main htdocs folder. In order to display your project, you use www.mywebsite.com/myproject. You should change the DocumentRoot. For example:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/your-project-folder"
ServerName www.mywebsite.com
</VirtualHost>
Tested on Win 8.1 Pro x64, XAMPP 5.6.21 portable. It's working.
Open the file index.php from the htdocs in xammp ( ..\xampp\htdocs\index.php)
Change the line
header('Location: '.$uri.'/dashboard/');
to
header('Location: '.$uri.'/yoursitefolder/');
this will resolve the issue.

How to access a site on Codero without a domain name and without appending the username to the end

Yesterday i have created a new site on my Codero Dedicated Server. and i have not assigned any domain name yet to the ip address.
Currently i am able to access my site with http://MySiteIpAddress/~username but i want to access it with only http://MySiteIpAddress/. Is there any way to do it. I don't know if that's possible by htaccess rules, so any hints are appreciated.
You want to setup a virtual host and point it to the folder you want.
See this other post for more details.
You need to do several steps in order to make this work.
1.) Update the hosts file. On Windows XP, you can find it under c:\WINDOWS\system32\drivers\etc\. You should already see the first
line from below, it takes care of your mentioned other project. - add
the additional ones to make any requests to the mentioned virtual
hosts routed back to your own machine.
127.0.0.1 localhost
127.0.0.1 foo-bar.com
127.0.0.1 abcdef.com
127.0.0.1 qwerty.com
2.) Update the vhosts file in Apache configuration. Under your XAMPP folder, add the following to
apache\conf\extra\httpd-vhosts.conf and if needed change the ports
(i.e. if you use 8080 instead of port 80).
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/foo-bar/
ServerName www.foo-bar.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/abcdef/
ServerName www.abcdef.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/xampplite/htdocs/qwerty/web/
ServerName www.qwerty.com
</VirtualHost>
3.) Do a quick configuration check. Open {XAMPP-folder}\apache\conf\httpd.conf your file and make sure that
the following part is not commented out by a preceeding # character:
Include conf/extra/httpd-vhosts.conf
4.) Restart XAMPP.
... and you should be all setup now. Your other project should
be accessible at the URI you mentioned if you just put it under
C:/xampplite/htdocs/my-project/.

htaccess root domain and sub domain direction

Hi can you help me about this ? because I dont know how I am supposed to solve it.
I am getting the problem if I write mysite.com/australia/ or mysite.com/australia/something ERROR 404 - PAGE NOT FOUND but if I write www.mysite.com/australia/ site is perfectly open
I am getting another problem if I write my subdomain name like this www.test.mysite.com/ it is showing Server not found but if I try test.mysite.com/ or photo.mysite.com/ then site is perfectly open
how can I solve this kind of problem?
You need to edit the apache conf file and add a server alias:
<VirtualHost *:80>
# This first-listed virtual host is also the default for *:80
ServerName www.example.com
ServerAlias example.com
DocumentRoot "/www/domain"
</VirtualHost>
See: http://httpd.apache.org/docs/2.4/vhosts/name-based.html

Why does my virtual host XAMPP not be able to display the php file?

I am trying to set up a virtual host so that I can run my .php file from Eclipse as a web page.
I follow the instructions from this discussion:
Make XAMPP/Apache serve file outside of htdocs
Scroll down to virtual hosts and the instruction is basically
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Users/Oky/Documents/eclipse/firstEclipseProject/"
ServerName firstEclipseProject.localhost
ErrorLog "/Users/Oky/Documents/eclipse/firstEclipseProject/logs/error_log"
<Directory /Users/Oky/Documents/eclipse/firstEclipseProject/>
Order allow,deny
Allow from all
</Directory>
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
The document is at /Application/XAMPP/etc/extra/httpd-vhosts.conf
Then I change the hosts file at /private/etc/hosts and at the bottom, I added
127.0.0.1 firstEclipseProject.localhost #firstEclipseProject
So, I think I am doing it right up to this point because when I fire my browser and point to firsteclipseproject.localhost, it redirects me to
firsteclipseproject.localhost/XAMPP/
which is the main XAMPP web page. It does not return an object/page not found which means the redirecting is somewhat working.
So, in /Users/Oky/Documents/eclipse/firstEclipseProject/
I created a php file called HelloWorld.php but when I point to firsteclipseproject.localhost/HelloWorld.php, it says object not found! I also tried firsteclipseproject.localhost/XAMPP/HelloWorld.php and it fails.
Any help is appreciated! Thanks!!!
I would suggest you leave the root directory the way it is and instead setup an Alias to your eclipse directory.
Did you restart apache after making config changes?

Categories