Laravel 4 removing public from URL

后端 未结 20 1981
一个人的身影
一个人的身影 2020-11-29 04:33

So, I\'m running xampp on Windows. I\'m currently trying to get familiar with the laravel framework. Now, when thats pointed out. How can i be able to access my laravel appl

相关标签:
20条回答
  • 2020-11-29 04:47

    if you remove public from url first of all move index.php and .htaccess file from public folder to root of the laravel and change in index.php file

    require DIR.'/../bootstrap/autoload.php'; $app = require_once DIR.'/../bootstrap/start.php';

    to

    require DIR.'/bootstrap/autoload.php'; $app = require_once DIR.'/bootstrap/start.php';

    and run the program

    0 讨论(0)
  • 2020-11-29 04:48

    Move the contents of the /public folder down a level.

    You'll need to update the include lines in index.php to point to the correct location. (if it's down a level, remove the '../').

    0 讨论(0)
  • 2020-11-29 04:48

    If you don't wish to go through the stress of configuring .htaccess file, you could use PHP Built-in Server by doing this:

    1. From your command utility, cd into laravel\public
    2. The run: php -S localhost:8000

    After you can access your website by going to:

    http:://localhost:8000

    works without appending public

    See the official manual to learn more: http://php.net/manual/en/features.commandline.webserver.php

    0 讨论(0)
  • 2020-11-29 04:51

    You can use symlinks or edit the httpd.conf file.

    Check my answer to another similar question. I hope that it helps.

    0 讨论(0)
  • 2020-11-29 04:53

    Add following code in your .htaccess (if not exist create a .htaccess on laravel root directory)

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    

    Source : http://tutsnare.com/remove-public-from-url-laravel/

    at Source you also get another method to do same.

    Update : Preferred way to do it is make change in directory structure which explain in source URL.

    0 讨论(0)
  • 2020-11-29 04:55

    Easiest way is create .htaccess file in your Laravel root with following content:

    <IfModule mod_rewrite.c>
        RewriteEngine On
        RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    

    It should be redirected easily.

    Reference: https://coderwall.com/p/erbaig/laravel-s-htaccess-to-remove-public-from-url

    0 讨论(0)
提交回复
热议问题