0

suppose my site open with the url https://www.example.com and it also opens with the https://www.example.com/index.php but i want it to open only with the https://www.example.com ONLY and not with https://www.example.com/index.php

just want to know how to remove index.php from my url

  • Does this answer your question? [How Can I Remove “public/index.php” in the URL Generated Laravel?](https://stackoverflow.com/questions/23837933/how-can-i-remove-public-index-php-in-the-url-generated-laravel) – Buttered_Toast Feb 03 '22 at 14:10

2 Answers2

0

Create a file .htaccess in your root directory and add the below code in .htaccess file.

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

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]

RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ public/$1

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ server.php
</IfModule>
0

You can create a route with https://www.example.com/index.php that will redirect to user to https://www.example.com whenever user try to access https://www.example.com/index.php.

Eg. In you web.php file you can add a route like this.

Route::get('https://www.example.com/index.php', function () { 
    return redirect('https://www.example.com');
});
onkaram
  • 234
  • 1
  • 6