【问题标题】:URL with trailing slashes gets redirected to localhost in laravel 5 [duplicate]带有斜杠的 URL 在 laravel 5 中被重定向到 localhost [重复]
【发布时间】:2015-08-26 20:46:33
【问题描述】:

重复问题中的修复不起作用。

我尝试了 stackoverflow 中的所有修复,但似乎没有任何效果 laravel trailing Slashes redirect to localhost

路线

Route::get('/admin', array('as' => 'admin', 'uses' => 'Admin\Admin@getLogin'));

此网址运行良好 http://localhost/app/admin

但是当我在它前面添加一个斜杠时http://localhost/app/admin/ 它被重定向到http://localhost/admin

救命!

【问题讨论】:

  • 我说过它不起作用。请阅读我的问题。
  • 你的htaccess是什么?你能和我们分享一下吗?
  • 知道如何解决吗?

标签: php .htaccess laravel redirect laravel-5


【解决方案1】:

我也有这个问题,我需要将上述内容与其他帖子的建议结合起来。不记得从哪个帖子 无论如何,这是我的 .htaccess 让我正常工作。
还有 1 件事我们的项目在 url 中没有公开。

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

    RewriteEngine On
    RewriteBase /PROJECT_NAME

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

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

【讨论】:

    【解决方案2】:

    添加了这个,它起作用了!

    RewriteCond %{REQUEST_URI} !^
    
    猜你喜欢
    • 2015-12-25
    • 2016-03-08
    • 2015-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-19
    相关资源
    最近更新 更多