如何仅从url而不是index.php中删除public

如何仅从url而不是index.php中删除public,php,laravel,.htaccess,url,Php,Laravel,.htaccess,Url,在我的urlhttp://example.com/public/index.php在my laravel网站上。 我只想删除public memory not index.php 我想查看我的url,如http://example.com/index.php 公共访问 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes <

在我的url
http://example.com/public/index.php
在my laravel网站上。 我只想删除public memory not index.php 我想查看我的url,如
http://example.com/index.php

公共访问

<IfModule mod_rewrite.c>

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

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

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

选项-多视图-索引
重新启动发动机
#句柄授权头
RewriteCond%{HTTP:Authorization}。
重写规则。*-[E=HTTP\U授权:%{HTTP:AUTHORIZATION}]
#如果不是文件夹,则重定向尾部斜杠。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_URI}(+)/$
重写规则^1[L,R=301]
#处理前控制器。。。
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^index.php[L]

如果只想删除public而不想删除index,可以使用rewritebase

# invoke rewrite engine
    RewriteEngine On
    RewriteBase /~app-folder-name/

# add trailing slash if missing
    rewriteRule ^(([a-z0-9\-]+/)*[a-z0-9\-]+)$ $1/ [NC,R=301,L]

如果要删除公用/索引,请在apache2配置中设置文档根。

.htaccess
文件从
public
文件夹复制到根文件夹,并用以下代码替换代码

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

RewriteEngine On


RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1 

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php

选项-多视图
重新启动发动机
RewriteCond%{REQUEST_FILENAME}-d[或]
RewriteCond%{REQUEST_FILENAME}-f
重写规则^^$1[N]
重写条件%{REQUEST\u URI}(\.\w+$)[NC]
重写规则^(.*)$public/$1
重写cond%{REQUEST_FILENAME}-D
重写cond%{REQUEST_FILENAME}-F
重写规则^server.php

请尝试代码并让我知道。

可能重复编号。请删除public/index.php。但是我只想删除public而不是index.php。记住not index.php当我的一个演示项目上线时,我只是将我的子域指向公用文件夹路径。因此,现在
public
没有出现在URL中,而且一切都运行得很好。不明白为什么人们会在这里处理这么多.htaccess.RewriteBase/~app folder name/添加哪个文件夹名?@MizanurRahman您的项目文件夹公用目录可能类似于
myapp/public/
如果您的htaccess在项目文件夹外,如果您的htaccess文件在项目文件夹内,我猜它只会是
public/
的。RewriteBase public/像那样吗?@MizanurRahman只需将文本
app文件夹名
替换为您的文件夹名。请查看我的问题详细信息,并尝试理解。我可以删除public/index.php,但不能只删除public。