简体   繁体   English

Laravel 从 index.php 和 index.html 重定向到域

[英]Laravel redirect from index.php and index.html to domain

I am beginner webdeveloper.我是初学者网络开发人员。 I have small problem with redirect.我有重定向的小问题。

I have this htacess:我有这个 htacess:

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

    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

    RewriteCond %{HTTPS} !on
    RewriteRule (.*) https://domain.pl [R=301,L]

    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]

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

It's work fine.它工作正常。 Now I need redirect from https://domain.pl/index.php and https://domain.pl.html to https://domain.pl现在我需要从https://domain.pl/index.phphttps://domain.pl.html重定向到https://domain.pl

I use Laravel 8.我使用 Laravel 8。

How can I make it?我怎样才能做到?

最简单的方法是

Route::get('/index.html', function(){ return redirect('http://domain/'); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM