【问题标题】:How rewrite .htaccess file conditions for laravel?如何为 laravel 重写 .htaccess 文件条件?
【发布时间】:2018-11-13 07:51:23
【问题描述】:

请帮忙。我希望我的 apache web 服务器将在没有 public folder 的情况下加载我的项目,该项目具有 index.php 文件。

如何重写当前 URL 'http://localhost/couponsystem/public/'

对于''http://localhost/couponsystem/

<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 ^(.*)$ public/$1 [L]

【问题讨论】:

    标签: php laravel apache


    【解决方案1】:

    试试这个.htaccess 文件

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

    按照以下步骤进行操作:

    • 将 Laravel 根文件夹中的 server.php 重命名为 index.php
    • .htaccess 文件从/public 目录复制到你的Laravel 根目录 文件夹。

    Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多