如何删除“公共/索引”。php在url中生成laravel?

时间:2022-06-13 11:17:53

Basically I need to remove index.php or public/index.php from the the generated URL in laravel, commonly path is localhost/public/index.php/someWordForRoute, It should be something like localhost/someWordForRoute

基本上我需要删除索引。php或公共/索引。php从laravel中生成的URL,通常路径是localhost/public/index。php/someWordForRoute,它应该类似于localhost/someWordForRoute

htacces

htacces

<IfModule mod_rewrite.c><IfModule mod_negotiation.c>Options -MultiViews</IfModule>RewriteEngine On# Redirect Trailing Slashes...RewriteRule ^(.*)/$ /$1 [L,R=301]# Handle Front Controller...RewriteCond %{REQUEST_FILENAME} !-dRewriteCond %{REQUEST_FILENAME} !-fRewriteRule ^ index.php[L]

app/config/app.php

应用程序/配置/ app.php

'url' => 'http://localhost',

how can I change that?

我怎么才能改变呢?

14 个解决方案

#1


93  

Option 1: Use .htaccess

If it isn't already there, create an .htaccess file in the Laravel root directory.Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)

如果还没有,在Laravel根目录中创建一个.htaccess文件。如果Laravel的根目录不存在,则创建一个.htaccess文件。(通常在public_html文件夹下)

Edit the .htaccess file so that it contains the following code:

编辑.htaccess文件,使其包含以下代码:

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

Now you should be able to access the website without the "/public/index.php/" part.

现在,您应该可以访问没有“/public/index”的网站。php /”部分。

Option 2 : Move things in the '/public' directory to the root directory

Make a new folder in your root directory and move all the files and folder except public folder. You can call it anything you want. I'll use "laravel_code".

在根目录中创建一个新文件夹,并移动除公用文件夹之外的所有文件和文件夹。你想叫什么就叫什么。我将使用“laravel_code”。

Next, move everything out of the public directory and into the root folder. It should result in something somewhat similar to this:如何删除“公共/索引”。php在url中生成laravel?

接下来,将所有内容从公共目录移到根文件夹。它应该导致类似的情况:

After that, all we have to do is edit the locations in the laravel_code/bootstrap/paths.php file and the index.php file.

之后,我们要做的就是编辑laravel_code/bootstrap/路径中的位置。php文件和索引。php文件。

In laravel_code/bootstrap/paths.php find the following line of code:

在laravel_code /引导/路径。php代码如下:

'app' => __DIR__.'/../app','public' => __DIR__.'/../public',

And change them to:

和改变他们:

'app' => __DIR__.'/../app','public' => __DIR__.'/../../',

In index.php, find these lines:

在索引。php,发现这些线:

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

And change them to:

和改变他们:

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

Source: How to remove /public/ from URL in Laravel

来源:如何删除/公开/从拉拉维尔的URL

#2


35  

I tried this on Laravel 4.2

我在Laravel 4.2上试过这个

Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder.

重命名服务器。php在Laravel的根文件夹中的索引。将.htaccess文件从/public目录复制到Laravel根文件夹。

I hope it works

我希望它工作

#3


11  

HERE ARE SIMPLE STEPS TO REMOVE PUBLIC IN URL (Laravel 5)

以下是在URL中删除PUBLIC的简单步骤(Laravel 5)

1: Copy all files form public folder and past them in laravel root folder

1:将所有文件复制到公共文件夹中,并在laravel的根文件夹中

2: Open index.php and change

2:打开索引。php和改变

From

 require __DIR__.'/../bootstrap/autoload.php';

To

 require __DIR__.'/bootstrap/autoload.php';

And

$app = require_once __DIR__.'/../bootstrap/app.php';

To

$app = require_once __DIR__.'/bootstrap/app.php';

In laravel 4 path 2 is $app = require_once __DIR__.'/bootstrap/start.php'; instead of $app = require_once __DIR__.'/bootstrap/app.php';/app.php

在laravel 4路径2中,$app = require_once __DIR__.'/bootstrap/start.php';而不是$app = require_once __DIR__.'/bootstrap/app.php';/app.php

That is it.

就是这样。

#4


9  

1) Check whether mod_rewrite is enabled. Go to /etc/apache2/mods-enabled directory and see whether the rewrite.load is available. If not, enable it using the command sudo a2enmod rewrite.It will enable the rewrite module. If its already enabled, it will show the message Module rewrite already enabled.
2)Create a virtual host for public directory so that instead of giving http://localhost/public/index.php we will be able to use like that http://example.com/index.php. [hence public folder name will be hidded]
3)Then create a .htaccess which will hide the index.php from your url which shoul be inside the root directory (public folder)

1)检查是否启用mod_rewrite。转到/etc/apache2/mods-enabled目录,看看是否重写。负载是可用的。如果不是,则使用sudo a2enmod重写命令启用它。它将启用重写模块。如果它已经启用,它将显示已启用的消息模块重写。2)为公共目录创建一个虚拟主机,以便不提供http://localhost/public/index。我们可以像这样使用http://example.com/index.php。然后创建一个.htaccess来隐藏索引。您的url中的php,它位于根目录(公用文件夹)中

RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /index.php?/$1 [L]

#5


7  

Don't get confused with other option the snippet below I am using and will be useful for you too.Put the below htacces in your root.

不要混淆我正在使用的其他选项,也将对您有用。把下面的htacces放在你的根上。

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

Go to your public directory and put another htaccess file with the code snippet below

转到您的公共目录,并将另一个htaccess文件与下面的代码片段连接起来。

<IfModule mod_rewrite.c>    RewriteEngine On    # Removes index.php from ExpressionEngine URLs      RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]</IfModule>

Its working... !!!

它的工作…! ! !

#6


3  

This likely has very little to do with Laravel and everything to do with your Apache configs.

这可能与Laravel无关,而与Apache configs有关。

Do you have access to your Apache server config? If so, check this out, from the docs:

您有访问Apache服务器配置的权限吗?如果是的话,请查看文档:

In general, you should only use .htaccess files when you don't have access to the main server configuration file. There is, for example, a common misconception that user authentication should always be done in .htaccess files, and, in more recent years, another misconception that mod_rewrite directives must go in .htaccess files. This is simply not the case. You can put user authentication configurations in the main server configuration, and this is, in fact, the preferred way to do things. Likewise, mod_rewrite directives work better, in many respects, in the main server configuration.

通常,您应该只在无法访问主服务器配置文件时使用.htaccess文件。例如,有一个常见的误解,即用户身份验证应该始终在.htaccess文件中进行,并且在最近几年,另一个误解是mod_rewrite指令必须放在.htaccess文件中。事实并非如此。您可以将用户身份验证配置放在主服务器配置中,实际上,这是首选的方式。同样,在主服务器配置中,mod_rewrite指令在很多方面都能更好地工作。

... In general, use of .htaccess files should be avoided when possible. Any configuration that you would consider putting in a .htaccess file, can just as effectively be made in a section in your main server configuration file.

…一般来说,应该尽可能避免使用.htaccess文件。您可以考虑将任何配置放入.htaccess文件中,也可以在主服务器配置文件的某个部分中有效地进行。

Source: Apache documentation.

来源:Apache文档。

The reason why I mention this first is because it is best to get rid of .htaccess completely if you can,and use a Directory tag inside a VirtualHost tag. That being said, the rest of this is going to assume you are sticking with the .htaccess route for whatever reason.

我之所以首先提到这一点,是因为如果可以,最好完全删除.htaccess,并在VirtualHost标记中使用目录标记。话虽如此,其余部分将假定您出于某种原因而坚持使用。htaccess路径。

To break this down, a couple things could be happening:

为了打破这一局面,可能会发生以下几件事:

  1. I note, perhaps pointlessly, that your file is named .htacces in your question. My guess is that it is a typo but on the off chance you overlooked it and it is in fact just missing the second s, this is exactly the sort of minor error that would leave me banging my head against the wall looking for something more challenging.

    我注意到,也许是毫无意义的,您的问题中,您的文件被命名为.htacces。我的猜测是,这是一个错误的错误,但你忽略了它,它实际上只是错过了第二个s,这是一个小错误,它会让我的头撞到墙上去寻找更有挑战性的东西。

  2. Your server could not be allowing .htaccess. To check this, go to your Apache configuration file. In modern Apache builds this is usually not in one config file so make sure you're using the one that points to your app, wherever it exists. Change

    您的服务器不能允许.htaccess。要检查这一点,请转到Apache配置文件。在现代Apache构建中,这通常不在一个配置文件中,所以请确保您使用的是指向应用程序的那个配置文件,无论它在哪里。改变

    AllowOverride none

    to

    AllowOverride all

    As a followup, the Apache documents also recommend that, for security purposes, you don't do this for every folder if you are going to go for .htaccess for rewriting. Instead, do it for the folders you need to add .htaccess to.

    作为后续,Apache文档还建议,出于安全目的,如果要使用.htaccess进行重写,那么不要对每个文件夹都这样做。相反,对需要添加.htaccess的文件夹执行此操作。

  3. Do you have mod_rewrite enabled? That could be causing the issues. I notice you have the tag at the top <IfModule mod_rewrite.c>. Try commenting out those tags and restart Apache. If you get an error then it is probably because you need to enable mod_rewrite:How to enable mod_rewrite for Apache 2.2

    是否启用了mod_rewrite ?这可能会引发问题。我注意到您有顶部 的标记。尝试注释掉这些标记并重新启动Apache。如果出现错误,可能是因为需要启用mod_rewrite:如何为Apache 2.2启用mod_rewrite

Hope this helps. I've named some of the most common issues but there are several others that could be more mundane or unique. Another suggestion on a dev server? Re-install Apache. If possible, do so from a different source with a good tutorial.

希望这个有帮助。我列举了一些最常见的问题,但也有一些其他的问题可能更平凡或更独特。关于开发服务器的另一个建议?安装Apache。如果可能的话,从一个不同的来源用一个好的教程做。

#7


1  

Laravel ships with a pretty URL .htaccess already... you should be good to go out of the box...http://laravel.com/docs/installation#pretty-urls

Laravel已经有了一个漂亮的URL。htaccess…你应该打开盒子…http://laravel.com/docs/installation#pretty-urls

Make sure mod_rewrite is enabled and that your home path is set to the public directory of your application.

确保mod_rewrite被启用,并且主路径被设置为应用程序的公共目录。

#8


1  

For Laravel 4 & 5:

对于Laravel 4和5:

  1. Rename server.php in your Laravel root folder to index.php
  2. 重命名服务器。php在Laravel的根文件夹中指向index.php
  3. Copy the .htaccess file from /public directory to your Laravel root folder.
  4. 将.htaccess文件从/公共目录复制到您的Laravel根文件夹。

Thats it !! :)

这就是它! !:)

#9


0  

 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

use this in .htaccess and restart the server

在.htaccess中使用它并重新启动服务器

#10


0  

Hope this helps like it did for me.

希望这对我有帮助。

<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_URI} !^publicRewriteRule ^(.*)$ public/$1 [L]</IfModule>

#11


0  

Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder. -- Thats it !! :)

重命名服务器。php在Laravel的根文件夹中的索引。将.htaccess文件从/public目录复制到Laravel根文件夹。——这是它! !:)

#12


0  

I just installed Laravel 5 for a project and there is a file in the root called server.php. Just change it to index.php and it works or in terminal, type

我刚刚为一个项目安装了Laravel 5,在根目录中有一个名为server.php的文件。把它改成index。php和它工作,或者在终端,输入

$cp server.php index.php

美元cp服务器。php index . php

#13


-3  

<IfModule mod_rewrite.c>RewriteEngine OnRewriteRule ^(.*)/(public)/(index.php)/$ $1/$4 [L]</IfModule>

#14


-3  

As per Laravel 5.3 the above things will not work properly, but please be calm and follow below steps:

根据Laravel 5.3所述,上述事项将无法正常工作,但请冷静下来,并遵循以下步骤:

Step 1. Go to inside of laravel project
Step 2. Make one random directory/folder eg. laravelcode
Step 3. Move all the folder and files(Except public folder)
Step 4. Move all the folder and files which are inside the public folder to the laravel project
Step 5. Now inside the laravel project there is index.php file, please open that and change the folder paths for bootstrap as per new path like previously it was "require DIR.'/../bootstrap/autoload.php';" now it will become to "require DIR.'/laravelcode/bootstrap/autoload.php';"

步骤1。进入laravel项目的内部步骤2。制作一个随机目录/文件夹。laravelcode步骤3。移动所有文件夹和文件(公共文件夹除外)步骤4。将公共文件夹中的所有文件夹和文件移动到laravel项目步骤5。现在在laravel项目中有索引。php文件,请打开它,按照之前的路径更改引导的文件夹路径,如“require DIR. /../ .. ../bootstrap/ autoloads .php';”现在将变成“require DIR.'/laravelcode/bootstrap/ autoloads .php';”

That's it just run your url without public and index.php like belowhttp://localhost/blog/

它只是在没有公共和索引的情况下运行你的url。像belowhttp php:/ / localhost /博客/

#1


93  

Option 1: Use .htaccess

If it isn't already there, create an .htaccess file in the Laravel root directory.Create a .htaccess file your Laravel root directory if it does not exists already. (Normally it is under your public_html folder)

如果还没有,在Laravel根目录中创建一个.htaccess文件。如果Laravel的根目录不存在,则创建一个.htaccess文件。(通常在public_html文件夹下)

Edit the .htaccess file so that it contains the following code:

编辑.htaccess文件,使其包含以下代码:

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

Now you should be able to access the website without the "/public/index.php/" part.

现在,您应该可以访问没有“/public/index”的网站。php /”部分。

Option 2 : Move things in the '/public' directory to the root directory

Make a new folder in your root directory and move all the files and folder except public folder. You can call it anything you want. I'll use "laravel_code".

在根目录中创建一个新文件夹,并移动除公用文件夹之外的所有文件和文件夹。你想叫什么就叫什么。我将使用“laravel_code”。

Next, move everything out of the public directory and into the root folder. It should result in something somewhat similar to this:如何删除“公共/索引”。php在url中生成laravel?

接下来,将所有内容从公共目录移到根文件夹。它应该导致类似的情况:

After that, all we have to do is edit the locations in the laravel_code/bootstrap/paths.php file and the index.php file.

之后,我们要做的就是编辑laravel_code/bootstrap/路径中的位置。php文件和索引。php文件。

In laravel_code/bootstrap/paths.php find the following line of code:

在laravel_code /引导/路径。php代码如下:

'app' => __DIR__.'/../app','public' => __DIR__.'/../public',

And change them to:

和改变他们:

'app' => __DIR__.'/../app','public' => __DIR__.'/../../',

In index.php, find these lines:

在索引。php,发现这些线:

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

And change them to:

和改变他们:

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

Source: How to remove /public/ from URL in Laravel

来源:如何删除/公开/从拉拉维尔的URL

#2


35  

I tried this on Laravel 4.2

我在Laravel 4.2上试过这个

Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder.

重命名服务器。php在Laravel的根文件夹中的索引。将.htaccess文件从/public目录复制到Laravel根文件夹。

I hope it works

我希望它工作

#3


11  

HERE ARE SIMPLE STEPS TO REMOVE PUBLIC IN URL (Laravel 5)

以下是在URL中删除PUBLIC的简单步骤(Laravel 5)

1: Copy all files form public folder and past them in laravel root folder

1:将所有文件复制到公共文件夹中,并在laravel的根文件夹中

2: Open index.php and change

2:打开索引。php和改变

From

 require __DIR__.'/../bootstrap/autoload.php';

To

 require __DIR__.'/bootstrap/autoload.php';

And

$app = require_once __DIR__.'/../bootstrap/app.php';

To

$app = require_once __DIR__.'/bootstrap/app.php';

In laravel 4 path 2 is $app = require_once __DIR__.'/bootstrap/start.php'; instead of $app = require_once __DIR__.'/bootstrap/app.php';/app.php

在laravel 4路径2中,$app = require_once __DIR__.'/bootstrap/start.php';而不是$app = require_once __DIR__.'/bootstrap/app.php';/app.php

That is it.

就是这样。

#4


9  

1) Check whether mod_rewrite is enabled. Go to /etc/apache2/mods-enabled directory and see whether the rewrite.load is available. If not, enable it using the command sudo a2enmod rewrite.It will enable the rewrite module. If its already enabled, it will show the message Module rewrite already enabled.
2)Create a virtual host for public directory so that instead of giving http://localhost/public/index.php we will be able to use like that http://example.com/index.php. [hence public folder name will be hidded]
3)Then create a .htaccess which will hide the index.php from your url which shoul be inside the root directory (public folder)

1)检查是否启用mod_rewrite。转到/etc/apache2/mods-enabled目录,看看是否重写。负载是可用的。如果不是,则使用sudo a2enmod重写命令启用它。它将启用重写模块。如果它已经启用,它将显示已启用的消息模块重写。2)为公共目录创建一个虚拟主机,以便不提供http://localhost/public/index。我们可以像这样使用http://example.com/index.php。然后创建一个.htaccess来隐藏索引。您的url中的php,它位于根目录(公用文件夹)中

RewriteEngine OnRewriteCond %{REQUEST_FILENAME} !-fRewriteCond %{REQUEST_FILENAME} !-dRewriteRule ^(.*)$ /index.php?/$1 [L]

#5


7  

Don't get confused with other option the snippet below I am using and will be useful for you too.Put the below htacces in your root.

不要混淆我正在使用的其他选项,也将对您有用。把下面的htacces放在你的根上。

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

Go to your public directory and put another htaccess file with the code snippet below

转到您的公共目录,并将另一个htaccess文件与下面的代码片段连接起来。

<IfModule mod_rewrite.c>    RewriteEngine On    # Removes index.php from ExpressionEngine URLs      RewriteCond %{REQUEST_FILENAME} !-f    RewriteCond %{REQUEST_FILENAME} !-d    RewriteRule ^(.*)$ index.php?url=$1 [PT,L]</IfModule>

Its working... !!!

它的工作…! ! !

#6


3  

This likely has very little to do with Laravel and everything to do with your Apache configs.

这可能与Laravel无关,而与Apache configs有关。

Do you have access to your Apache server config? If so, check this out, from the docs:

您有访问Apache服务器配置的权限吗?如果是的话,请查看文档:

In general, you should only use .htaccess files when you don't have access to the main server configuration file. There is, for example, a common misconception that user authentication should always be done in .htaccess files, and, in more recent years, another misconception that mod_rewrite directives must go in .htaccess files. This is simply not the case. You can put user authentication configurations in the main server configuration, and this is, in fact, the preferred way to do things. Likewise, mod_rewrite directives work better, in many respects, in the main server configuration.

通常,您应该只在无法访问主服务器配置文件时使用.htaccess文件。例如,有一个常见的误解,即用户身份验证应该始终在.htaccess文件中进行,并且在最近几年,另一个误解是mod_rewrite指令必须放在.htaccess文件中。事实并非如此。您可以将用户身份验证配置放在主服务器配置中,实际上,这是首选的方式。同样,在主服务器配置中,mod_rewrite指令在很多方面都能更好地工作。

... In general, use of .htaccess files should be avoided when possible. Any configuration that you would consider putting in a .htaccess file, can just as effectively be made in a section in your main server configuration file.

…一般来说,应该尽可能避免使用.htaccess文件。您可以考虑将任何配置放入.htaccess文件中,也可以在主服务器配置文件的某个部分中有效地进行。

Source: Apache documentation.

来源:Apache文档。

The reason why I mention this first is because it is best to get rid of .htaccess completely if you can,and use a Directory tag inside a VirtualHost tag. That being said, the rest of this is going to assume you are sticking with the .htaccess route for whatever reason.

我之所以首先提到这一点,是因为如果可以,最好完全删除.htaccess,并在VirtualHost标记中使用目录标记。话虽如此,其余部分将假定您出于某种原因而坚持使用。htaccess路径。

To break this down, a couple things could be happening:

为了打破这一局面,可能会发生以下几件事:

  1. I note, perhaps pointlessly, that your file is named .htacces in your question. My guess is that it is a typo but on the off chance you overlooked it and it is in fact just missing the second s, this is exactly the sort of minor error that would leave me banging my head against the wall looking for something more challenging.

    我注意到,也许是毫无意义的,您的问题中,您的文件被命名为.htacces。我的猜测是,这是一个错误的错误,但你忽略了它,它实际上只是错过了第二个s,这是一个小错误,它会让我的头撞到墙上去寻找更有挑战性的东西。

  2. Your server could not be allowing .htaccess. To check this, go to your Apache configuration file. In modern Apache builds this is usually not in one config file so make sure you're using the one that points to your app, wherever it exists. Change

    您的服务器不能允许.htaccess。要检查这一点,请转到Apache配置文件。在现代Apache构建中,这通常不在一个配置文件中,所以请确保您使用的是指向应用程序的那个配置文件,无论它在哪里。改变

    AllowOverride none

    to

    AllowOverride all

    As a followup, the Apache documents also recommend that, for security purposes, you don't do this for every folder if you are going to go for .htaccess for rewriting. Instead, do it for the folders you need to add .htaccess to.

    作为后续,Apache文档还建议,出于安全目的,如果要使用.htaccess进行重写,那么不要对每个文件夹都这样做。相反,对需要添加.htaccess的文件夹执行此操作。

  3. Do you have mod_rewrite enabled? That could be causing the issues. I notice you have the tag at the top <IfModule mod_rewrite.c>. Try commenting out those tags and restart Apache. If you get an error then it is probably because you need to enable mod_rewrite:How to enable mod_rewrite for Apache 2.2

    是否启用了mod_rewrite ?这可能会引发问题。我注意到您有顶部 的标记。尝试注释掉这些标记并重新启动Apache。如果出现错误,可能是因为需要启用mod_rewrite:如何为Apache 2.2启用mod_rewrite

Hope this helps. I've named some of the most common issues but there are several others that could be more mundane or unique. Another suggestion on a dev server? Re-install Apache. If possible, do so from a different source with a good tutorial.

希望这个有帮助。我列举了一些最常见的问题,但也有一些其他的问题可能更平凡或更独特。关于开发服务器的另一个建议?安装Apache。如果可能的话,从一个不同的来源用一个好的教程做。

#7


1  

Laravel ships with a pretty URL .htaccess already... you should be good to go out of the box...http://laravel.com/docs/installation#pretty-urls

Laravel已经有了一个漂亮的URL。htaccess…你应该打开盒子…http://laravel.com/docs/installation#pretty-urls

Make sure mod_rewrite is enabled and that your home path is set to the public directory of your application.

确保mod_rewrite被启用,并且主路径被设置为应用程序的公共目录。

#8


1  

For Laravel 4 & 5:

对于Laravel 4和5:

  1. Rename server.php in your Laravel root folder to index.php
  2. 重命名服务器。php在Laravel的根文件夹中指向index.php
  3. Copy the .htaccess file from /public directory to your Laravel root folder.
  4. 将.htaccess文件从/公共目录复制到您的Laravel根文件夹。

Thats it !! :)

这就是它! !:)

#9


0  

 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L]

use this in .htaccess and restart the server

在.htaccess中使用它并重新启动服务器

#10


0  

Hope this helps like it did for me.

希望这对我有帮助。

<IfModule mod_rewrite.c>RewriteEngine onRewriteCond %{REQUEST_URI} !^publicRewriteRule ^(.*)$ public/$1 [L]</IfModule>

#11


0  

Rename the server.php in the your Laravel root folder to index.php and copy the .htaccess file from /public directory to your Laravel root folder. -- Thats it !! :)

重命名服务器。php在Laravel的根文件夹中的索引。将.htaccess文件从/public目录复制到Laravel根文件夹。——这是它! !:)

#12


0  

I just installed Laravel 5 for a project and there is a file in the root called server.php. Just change it to index.php and it works or in terminal, type

我刚刚为一个项目安装了Laravel 5,在根目录中有一个名为server.php的文件。把它改成index。php和它工作,或者在终端,输入

$cp server.php index.php

美元cp服务器。php index . php

#13


-3  

<IfModule mod_rewrite.c>RewriteEngine OnRewriteRule ^(.*)/(public)/(index.php)/$ $1/$4 [L]</IfModule>

#14


-3  

As per Laravel 5.3 the above things will not work properly, but please be calm and follow below steps:

根据Laravel 5.3所述,上述事项将无法正常工作,但请冷静下来,并遵循以下步骤:

Step 1. Go to inside of laravel project
Step 2. Make one random directory/folder eg. laravelcode
Step 3. Move all the folder and files(Except public folder)
Step 4. Move all the folder and files which are inside the public folder to the laravel project
Step 5. Now inside the laravel project there is index.php file, please open that and change the folder paths for bootstrap as per new path like previously it was "require DIR.'/../bootstrap/autoload.php';" now it will become to "require DIR.'/laravelcode/bootstrap/autoload.php';"

步骤1。进入laravel项目的内部步骤2。制作一个随机目录/文件夹。laravelcode步骤3。移动所有文件夹和文件(公共文件夹除外)步骤4。将公共文件夹中的所有文件夹和文件移动到laravel项目步骤5。现在在laravel项目中有索引。php文件,请打开它,按照之前的路径更改引导的文件夹路径,如“require DIR. /../ .. ../bootstrap/ autoloads .php';”现在将变成“require DIR.'/laravelcode/bootstrap/ autoloads .php';”

That's it just run your url without public and index.php like belowhttp://localhost/blog/

它只是在没有公共和索引的情况下运行你的url。像belowhttp php:/ / localhost /博客/