laravel remove index.php from the url

1

I have a site where I can access with

https://www.pagina.com

but also with

https://www.pagina.com/index.php

I would like NOT to be able to access with that index.php (seo questions)

my .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]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    
asked by Aabel Morales 03.12.2017 в 01:52
source

1 answer

1

You could ban access, generating a 403 Forbidden :

RewriteRule ^index\.php$ - [NC,F]


Or you could redirect to / :

RewriteRule ^index\.php$ / [NC,R=301,L]
  •   

    However, the latter should be linked to the first rule in your .htaccess, so that it redirects only once if it ends with a bar at the end, or if it ends with index.php , applying it to any index.php of any folder (not just root).

    # Redirect Trailing Slashes (and index.php) If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*?)(?:(?:^|/)index\.php)?/$ /$1 [NC,L,R=301]
    
answered by 14.12.2017 в 06:08