Laravel htaccess

前端 未结 5 799
逝去的感伤
逝去的感伤 2021-01-14 02:28

I\'ve setup a new install of Laravel on my local. It appears there are issues with htaccess or Apache settings. I\'ve researched for a number of hours and tried everything I

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-14 02:49

    In the root path create a .htaccess file with

    
    Options +FollowSymLinks
    RewriteEngine On
    
    RewriteCond %{REQUEST_URI} !^/public/ 
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    
    
    
    RewriteRule ^(.*)$ /public/$1 
    #RewriteRule ^ index.php [L]
    RewriteRule ^(/)?$ public/index.php [L] 
    
    

    In public directory create a .htaccess file

    
        
            Options -MultiViews -Indexes
        
    
        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]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    
    

    if you have done any changes in public/index.php file correct them with the right path then your site will be live.

    what will solve with this?

    • Hosting issue of laravel project.
    • Css not work on laravel.
    • Laravel site not work.
    • laravel site load with domain/public/index.php
    • laravel project does not redirect correctly

提交回复
热议问题