localhost/ going to laravel project - laravel

I am new to Laravel and while creating a new project, I wanted it to be named in Virtual Host. By this way,
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/logo/public"
ServerName logo.local
</VirtualHost>
I named it, defined IP address for it (127.0.0.1) in HOSTS file but now, when I write localhost/ in the address bar, instead of going to Xampp("Welcome to XAMPP"), it goes to my laravel project. I know that if I will define my localhost the same way, like
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
the problem will be solved but I don't know the reason of doing this. Why do I need to name C:/xampp/htdocs/ as localhost, if it was default before my laravel project?

if i get your meanings correct, you need add a default virtual host before other virtual host, so in your case, should be like this,
add the code block to end of the httpd.conf
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/logo/public"
ServerName logo.local
</VirtualHost>
and edit hosts file to
127.0.0.1 localhost
127.0.0.1 logo.local

Related

Custom URL for project using Apache on Localhost

I am XAMPP on my localhost. When I go to localhost it's redirecting me to localhost/dashboard/ That's good.
now, I want If I type laravel.dev It's should load the laravel public folder
For that I configure httpd-vhosts file as below:
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "D:/xampp/htdocs/laravel-practice/public/"
ServerName laravel.dev
</VirtualHost>
windows hosts file like below:
127.0.0.1 localhost
127.0.0.1 laravel.dev
now, If I go to laravel.dev it's redirecting me to localhost/dashboard/ location. but its should be redirecting me to laravel public folder which is D:/xampp/htdocs/laravel-practice/public/
can you tell me how can I fix it?
If everything else is ok then change * to laravel.dev
<VirtualHost laravel.dev:80>
DocumentRoot "D:/xampp/htdocs/laravel-practice/public/"
ServerName laravel.dev
</VirtualHost>
Two important points:
Always restart apache after edit httpd-vhosts
Include NameVirtualHost laravel.dev:80 before <VirtualHost laravel.dev:80>
UPDATE
Xampp has a default index.php on htdocs folder, try deleting this file, because index.php redirects to /dashboard and let me know if worked

Laravel Setup Issue even after setting up Virtual Host and its all dependencies

I have installed Laravel Project with all its dependencies. Also, Setup Virtual Hosts for the same. But, When I hit the url like say "dev.laravelProject.com" it immediately opening Xampp Dashboard.
I don't know why is that happened.
Any Help Appreciated
First, change your /etc/hosts file to have a mapping of your desired website name(s) (www.example.com), and target IP address (127.0.0.1). I used my local IP address.
IPAddress Hostname Alias
----------- -------------------------- ------------------
127.0.0.1 www.librarymodule.com librarymodule.com
127.0.0.1 www.dev.librarymodule.com dev.librarymodule.com
So, you can set only one domain
<VirtualHost *:80>
DocumentRoot "/var/www/html/LibraryProject/public"
ServerName librarymodule.com
ServerAlias *.librarymodule.com
<Directory "/var/www/html/LibraryProject/public">
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
or add first the main one and then the subdomain:
<VirtualHost *:80>
DocumentRoot "/var/www/html/LibraryProject/public"
ServerName www.librarymodule.com
ServerAlias librarymodule.com
</VirtualHost>
<VirtualHost *:80>
ServerName www.dev.librarymodule.com
ServerAlias dev.librarymodule.com
DocumentRoot "/var/www/html/LibraryProject/public"
</VirtualHost>
As a final step, you may need to add the websites to Apache by issuing the below commands:
# a2ensite librarymodule.com
# a2ensite dev.librarymodule.com
- Reload apache.

laravel virtual host setup not showing front-end

I have a new laptop, and am now trying to run a laravel application.
First, am trying to setup a virtual host for the project so that I can access blog.local
I went my hosts file and setup the drivers like the following:
127.0.0.1 localhost
127.0.0.1 test.local
127.0.0.1 blog.local
The for the apache configuration I have the following:
<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs\blog"
ServerName blog.local
</VirtualHost>
When I try to access my url I do not see the site but the files only:
For this and future projects, how can I create a local url and see the front-end when I visit it?
You need to address your public folder,
<VirtualHost *:80>
DocumentRoot "C:\XAMPP\htdocs\blog\public"
ServerName blog.local
</VirtualHost>
The document root is a directory (a folder) that is stored on your host's servers and that is designated for holding web pages. When someone else looks at your website, this is the location they will be accessing.
Change the DocumentRoot to according to your PHP project is located.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/blog/public"
ServerName blog.local
</VirtualHost>
Restart the servers after making any changes! If you don’t reset the server to apply the changes, nothing will work even though you know you’ve done everything right.

Creating subdomains in Xampp server windows

I am trying to create sub-domains on my localhost to be accessed concurrently by my team but only the first project is loaded even when the url for the second domain is typed in the browser.
So far I have tried changing the httpd-vhosts.conf file
<VirtualHost *:80>
ServerAdmin webmaster#smartsacco.localhost.com
DocumentRoot "C:/xampp/htdocs/smartsacco/public"
ServerName smartsacco.localhost.com
ErrorLog "logs/smartsacco.localhost.com-error.log"
CustomLog "logs/smartsacco.localhost.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#mfarmer.localhost.com
DocumentRoot "C:/xampp/htdocs/Mfarmer/public"
ServerName mfarmer.localhost.com
ErrorLog "logs/mfarmer.localhost.com-error.log"
CustomLog "logs/mfarmer.localhost.com-access.log" common
</VirtualHost>
And also modified the hosts file
127.0.0.1 localhost
::1 localhost
127.0.0.1 smartsacco.localhost.com
127.0.0.1 mfarmer.localhost.com
Saddly only the contents of smartsacco.localhost.com is loaded even when I type mfarmer.localhost.com. What could Be wrong or and what can I do to have them both working?
Since your code is correct, I suggest you restart Apache server and maybe the entire computer

need help with xampp virtual host

I am using XAMPP, Apache 2.2.17. I have added virtual host but my virtual host and localhost both point to the same location. Here is my code in httpd-vhosts.conf
<VirtualHost www.domain.tld:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/testsite"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerAlias localhost
ServerName localhost
</VirtualHost>
With the above code, I get testsite with www.domain.tld so that is good. But If i type localhost, it will go to testsite as well. If I move ahead of test site then localhost goes to localhost good and www.domain.tld goes to localhost too. I tried different setting for localhost as like
<VirtualHost *>
<VirtualHost localhost:80>
and removing *.domain.tld from domain.tld but nothing works. Am I missing something obvious?
My own answer: The following code fixed the problem
<VirtualHost *:80> <--- * fixed the problem, apache 2.2 doc does say it must match www.domain.tld, which caused problem for other Virtual hosts
ServerName www.domain.tld
ServerAlias domain.tld
DocumentRoot "C:/xampp/htdocs/workspace/patriot2"
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/xampp"
ServerAlias localhost
ServerName localhost
</VirtualHost>
please change your ServerName from virtualhost to a local IP address such as 127.0.0.2.
ServerName domain.tld is an example of using "domain.com" where .tld is replaced by .com for your domain.

Resources