如何在 laravel 中重定向到 public
How to redirect to public in laravel
我将我的 laravel 项目从本地主机上传到服务器,但要访问应用程序,我的 url 是 http://myhostexample.com/public/ I want it to be http://myhostexample.com 我修改了 public/.htaccess 并在此处是:
<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} !^public
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/ [L]
</IfModule>
在 .htaccess 中你不应该改变任何东西;
您需要按照以下步骤部署 laravel 项目:
复制 laravel 项目中 public 文件夹的文件和文件夹并将其粘贴到 public_html
现在打开 public_html 并打开以编辑 index.php 文件
现在将 index.php 中的自动加载和 bootstrap 的路径更改为这些文件存在的位置
现在检查您的域
我将我的 laravel 项目从本地主机上传到服务器,但要访问应用程序,我的 url 是 http://myhostexample.com/public/ I want it to be http://myhostexample.com 我修改了 public/.htaccess 并在此处是:
<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} !^public
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ public/ [L]
</IfModule>
在 .htaccess 中你不应该改变任何东西;
您需要按照以下步骤部署 laravel 项目:
复制 laravel 项目中 public 文件夹的文件和文件夹并将其粘贴到 public_html
现在打开 public_html 并打开以编辑 index.php 文件
现在将 index.php 中的自动加载和 bootstrap 的路径更改为这些文件存在的位置
现在检查您的域