简体   繁体   中英

Laravel 4 in Subfolder MAMP

I'm using Wampserver on my windows computer, and my colleague is working on a mac with MAMP installed.

I changed my .htaccess file to get rid of the /public/ in the url, which worked fine, but this doesn't work on my buddy's computer with MAMP.

I have read you need to put all the files from the public folder in the root of the directory and change the paths.php and index.php . I've done this and it's not working because it is installed in a subfolder under the MAMP root, even tho I changed my .htaccess to adapt to this.

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On
    RewriteBase /laravel/
    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

I've been looking at this all day and it's really annoying me that I can't find the solution.

So what is the best and secure way to do this? how do I need to do this to be able to let it work on MAMP and a shared hosting? (and if possible also wampserver, altho that's not a requirement)

I'm not a fan of virtual hosts on MAMP, if I need to buy MAMP PRO to avoid this then I will, that's not a problem :-). If this is only possible through virtual hosts, then I'll have to do it I guess.

Thanks for the help guys and gals!

或者,您都可以使用artisan随附的内置php服务器

$ php artisan serve

You should setup up a vhost and add the domain to your hosts file. Don't do this through .htacces.

httpd-vhosts.conf

<VirtualHost *:80>
   DocumentRoot /path/to/your/project/public
   ServerName dev.yourproject.com
</VirtualHost>

Now edit your hosts file: http://helpdeskgeek.com/windows-7/windows-7-hosts-file/

Add this to your hosts file

127.0.0.1       yourproject.com

Now restart everything and your project should be available from http://dev.yourproject.com . Please don't use .htacces for this it is not necessary.

You can also try:

php -S localhost:7000 -t public/

This will fire up the PHP build in server on localhost:7000. Run the command from with the root of your project folder.

http://www.php.net/manual/en/features.commandline.webserver.php

You don't need to manually edit any Apache files when doing this sort of thing in MAMP. Just select the directory you want to use for www using the option in the control panel:

MAMP控制面板

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM