Laravel 5 – Remove Public from URL

后端 未结 30 2031
甜味超标
甜味超标 2020-11-22 03:20

I know this is a very popular question but I haven\'t been able to find a working solution for Laravel 5. I\'ve been trying to migrate from Codeigniter for a long time, but

30条回答
  •  误落风尘
    2020-11-22 03:49

    For XAMPP user to remove public from url without touching laravel default filesystem is to set a Virtual Host for your application to do this jsut follow these steps

    1. Open the XAMPP control panel application and stop Apache. Be aware that late Windows machines might run it as a service, so check the box to the left of the Apache module.

    2. Navigate to C:/xampp/apache/conf/extra or wherever your XAMPP files are located.

    3. Open the file named httpd-vhosts.conf with a text editor.

    4. Around line 19 find # NameVirtualHost *:80 and uncomment or remove the hash.

    5. At the very bottom of the file paste the following code:

    
        ServerAdmin admin@localhost.com
        DocumentRoot "C:/xampp/htdocs" # change this line with your htdocs folder
        ServerName localhost
        ServerAlias localhost
        
            Options Indexes FollowSymLinks Includes ExecCGI
            Order allow,deny
            Allow from all
        
    
    
    1. Now you can copy and paste the code above below to add your Virtual Host directories. For example I’m working on a site called Eatery Engine so the following snippet will allow me to work with sub-domains on my local install:
    
        ServerAdmin admin@localhost.com
        DocumentRoot "C:/xampp/htdocs/eateryengine" # change this line with your htdocs folder
        ServerName eateryengine.dev
        ServerAlias eateryengine.dev
        
            Order allow,deny
            Allow from all
        
    
    
    1. Next head over to your Windows host file to edit your HOSTS. the file will be located at C:/Windows/System32/drivers/etc/hosts, where hosts is the file. Open it with notepad.
    2. Look for #localhost name resolution is handled within DNS itself.

    127.0.0.1 localhost

    localhost name resolution is handled within DNS itself.

    127.0.0.1       localhost
    127.0.0.1       eateryengine.dev #change to match your Virtual Host.
    127.0.0.1       demo.eateryengine.dev #manually add new sub-domains.
    
    1. Restart Apache and test everything.

    The original article can be found here

提交回复
热议问题