【问题标题】:Laravel home url not working?Laravel 主页网址不起作用?
【发布时间】:2015-12-01 10:52:43
【问题描述】:

当我打开主页网址时:http://localhost/laravel/public/ 它会将我重定向到 http://localhost/public 并给我

错误 404

.htaccess 文件是默认文件,它曾经完美运行,我不知道出了什么问题?

这是.htaccess:

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

RewriteEngine On

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

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

【问题讨论】:

  • 你应该发布你的 htaccess 文件
  • @JoachimMartinsen 我是默认的 Laravel .htaccess
  • 你运行的是什么网络服务器?
  • @JoachimMartinsen 我正在使用 wamp

标签: php .htaccess laravel laravel-routing


【解决方案1】:

尝试将RewriteBase 添加到htaccess 文件中

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

RewriteEngine On
RewriteBase /laravel/public/

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

【讨论】:

    【解决方案2】:

    尝试使用以下 .htaccess 文件:

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>
    
        RewriteEngine On
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 2015-06-01
      • 2016-01-09
      • 1970-01-01
      • 2017-11-08
      • 2015-06-11
      • 2017-11-13
      • 2018-10-17
      • 2015-03-26
      • 1970-01-01
      相关资源
      最近更新 更多