MAMP virtual hosts keep sending me to 'Index of /' - laravel

I'm using Mac so I'm working with MAMP.
In /MAMP/conf/apache/httpd.config I did uncomment the second line:
#Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
Then in /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf I made this:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/User/xxxxx/Sites/mysite"
ServerName mysite
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/laravel-blog/public"
ServerName laravel-blog.dev
</VirtualHost>
And my etc/hosts looks like this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
127.0.0.1 mysite
127.0.0.1 laravel-blog.dev
so when I go to mysite:8888/ this redirects me to a page called
'Index of /' with all the folders that I have in htdocs
but when I go to laravel-blog.dev:8888/ it says the page failed to open
so I changed it: instead of laravel-blog.dev , I just used laravel-blog, changed it also in my /etc/hosts and in httpd-vhosts.conf file
and now when I go to laravel-blog:8888/ it redirects me back to this "Index of /" page, even tho the DocumentRoot is set to /Applications/MAMP/htdocs/laravel-blog/public
I have searched for hours and tried a lot of things but still nothing seems to redirect me to the '/public' page of an application, only redirects me back to the 'Index' which is the htdocs.
Anyone an explanation for this? how i can get to '/public'?
And why laravel-blog.dev is not accepted but laravel-blog is?
what has that .dev to do with anything?

All of this is a bit above me, but I find when I am redirecting using MAMP (not sure about MAMP PRO) I have to call the file index.(extension) or it will show the index of the whole folder. When you call the file index.(extension), it will open that file.
Hope this helps,
Nat

Related

How to configure virtual hosts to work in htdocs directory of Xampp?

I am following a laravel tutorial, where tutor sets up a virtual host to run their app. The app is located in /opt/lampp/htdocs/first-app. My port for running apache is 8000. So if I visit localhost:8000/first-app/public, I can view my laravel app.
My httpd-vhosts.conf file looks like this:
<VirtualHost *:8000>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "/opt/lampp/htdocs"
ServerName localhost
ServerAlias www.localhost
</VirtualHost>
<VirtualHost *:8000>
DocumentRoot "/opt/lampp/htdocs/first-app/public"
ServerName app.test
ServerAlias www.app.test
<Directory "/opt/lampp/htdocs/first-app">
Options All
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
My /etc/hosts file looks like this:
127.0.0.1 localhost app.test
::1 localhost app.test
127.0.1.1 pop-os.localdomain pop-os
127.0.0.1 app.test
I have uncommented httpd.conf like so
# Virtual hosts
Include etc/extra/httpd-vhosts.conf
But I am getting this when I visit app.test
Browser output when app.test is visited
What am I doing wrong?
Edit: I have discovered, if I visit www.app.test:8000, it works fine
Just found out that the browser automatically adds port 80. So since I am running apache on port 8000, I need to specify it.
Thus, the settings above actually worked. All I had to do was go to http://localhost:8000 or http://127.0.0.1:8000

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

Having trouble mapping Laravel public folder with a vhost on MAMP

I've got a Laravel project called "test" running on MAMP on my mac. I've uncommented the vhosts include line in httpd.conf and included this below in the vhosts file:
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Applications/MAMP/htdocs/test/public"
ServerName testapp.dev
</VirtualHost>
When I go to "testapp.dev" in my browser it just says the old
testapp.dev’s server IP address could not be found.
DNS_PROBE_FINISHED_NXDOMAIN
I'm not sure if I've missed something or what. Thanks in advance for your help! :)
(This is a repost but more clear)
So I ditched MAMP and used valet. I had some problems with that just going to localhost which was some random background apache server which I stopped and then everything worked! :)
if you are using windows edit C:\windows\system32\drivers\etc\hosts and if you are using unix edit /etc/hosts file and add this row at the end of file:
127.0.0.1 testapp.dev

Mac Osx Yosemite localhost document path errors

Working in Yosemite's localhost for a few months now. Previously I went through a simple configuration tutorial where the URL would be localhost/~username/project/public. Never really bothered me since I was just messing around with some simple sites. I recently ran into a problem with Laravel and Angular and its been suggested that my URL having the public in it was causing my routes to fail.
So I edited /etc/apache2/extra/httpd-vhosts.conf with
<VirtualHost *:80>
DocumentRoot "/Users/jeffcairoli/Sites/"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/jeffcairoli/Sites/time-tracker-2/public"
ServerName time-tracker-2.local
<directory "/Users/jeffcairoli/Sites/time-tracker-2/public/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
Allow from all
</directory>
</VirtualHost>
In /etc/hosts I added:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 time-tracker-2.local
In /etc/apache2/http.conf I uncommented the virtual hosts and vhost loadmodule.
When I visit time-tracker-2.com I am directed right to apache's It works! page.
I cannot figure out what I need to change to actually get it to point into my projects public folder so my laravel routes will take over. If anyone has any pointers or a better way to get my urls working please let me know. This issue is starting to drive me nuts.
**Update After making the changes to the vhosts and hosts files that I added here, I now get a 403 Forbidden when i visit localhost or time-tracker-2.local. localhost/~jeffcairoli brings me to the listing of all my files in my sites folder. Im not too sure if I am looking at this wrong or something. I've always had an issue getting these to work. Haven't been able to get any of the typical 403 fixes to work there but I think that tells me that at least its recognized my changes since the urls are actually giving me a response.
Adding another VirtualHost before that for localhost to be the default should fix your problem. Just try adding the following before your time-tracker2.com entry.
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "/Users/jeffcairoli/Sites/"
ServerName localhost
</VirtualHost>

Pulling my hair out with mod_rewrite and MAMP

I'm using MAMP and I can't get mod_rewrites to work.
After lots of playing with numerous http.conf files and then finally looked at my php_info, there is no mod_rewrite exstension installed.
I opened up the php.ini files in Applications > MAMP > conf > php5.2 & php5.3 and looked at the exstensions and there was no mod_rewrite.so. All I can see is:
extension=imap.so
extension=yaz.so
extension=mcrypt.so
extension=gettext.so
extension=pgsql.so
extension=pdo_pgsql.so
extension=pdo_mysql.so
I added it expecting a stroke of luck - but no joy!
I had the same problem and hopefully this will solve it for you.
I added my site in my host file so instead of going through the locahost/..... It had its own url that I redirected to 127.0.0.1. i.e. my host file looked like this
127.0.0.1 mysite.local
I then set up a virtual host in MAMP. You will find the vhosts.conf file in /Applications/MAMP/conf/apache
My host file looks like this
NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/mysite-folder"
ServerName mysite.local
</VirtualHost>
Hope that helps :D

Resources