Home  >  Article  >  PHP Framework  >  How to hide index.php in laravel

How to hide index.php in laravel

藏色散人
藏色散人Original
2021-05-27 09:40:593887browse

How to hide index.php in laravel: 1. Enable the Apache mod_rewrite module and modify the htaccess file; 2. Use the "try_files $uri $uri/..." instruction in the Nginx configuration file to hide index. php.

How to hide index.php in laravel

The operating environment of this article: windows7 system, Laravel version 5.7, DELL G3 computer

laravel configuration hidden index.php

Apache

First make sure your Apache mod_rewrite module is turned on. The framework has a public/.htaccess file by default that can hide access to index.php.

If it is invalid If so, you can try the following rules:

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

Nginx

Use the following instructions in the Nginx configuration file to hide index.php:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

Related recommendations : The latest five Laravel video tutorials

The above is the detailed content of How to hide index.php in laravel. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn