Laravel htaccess

前端 未结 5 729
逝去的感伤
逝去的感伤 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 03:06

    Answer

    Heres what I found that worked. Delete the .htaccess file inside the /public directory and then put the following into the laravel installation's document root.


    Clarification

    So for clarification if your laravel application is installed at /public_html/laravel you will look inside /public_html/laravel/public and delete the .htaccess file there. Then inside the /public_html/laravel directory make a new file called .htaccess


    Copy the code below to a new .htaccess file in the doc root

    
        
            Options -MultiViews
        
    
        RewriteEngine On
    
        # Redirect Trailing Slashes...
        RewriteRule ^(.*)/$ /public/$1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ public/index.php [L]
    
    

    Please note

    As Concordus Applications noted in their answer here make sure that the Loadmodule mod_rewrite is uncommented (make sure there is not a # symbol behind it in your apache config file)

    Concordus Applications also noted that you should have AllowOverride set to the appropriate setting. The example they gave was the following.

    
        Options Indexes Includes FollowSymLinks MultiViews
        AllowOverride AuthConfig FileInfo
        Order allow,deny
        Allow from all
     
    

    Please make sure to restart your apache server if you made any changes to your apache config file.

提交回复
热议问题