简体   繁体   中英

Laravel project is calling the wrong paths

I am new to Laravel and I am testing out an application that i have made. locally it works fine but when I push it to a server, then the routing seems to go really bad. Usually a path to a view would be like 156.0.125.1/app/index , but it keeps looking for 156.0.125.1/index which gives the error of URL not found on server

I suspect its the .htaccess file but I'm not too sure what to change there as I'm not familiar with it.

also the css and the js seem to not be read by the site on the server

heres the htaccess

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

    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]

    # Send Requests To Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

# Disable Directory listing
Options -Indexes

# block files which needs to be hidden, specify .example extension of the file
<Files ~ "\.(env|json|config.js|md|gitignore|gitattributes|lock)$">
    Order allow,deny
    Deny from all
</Files>

Move this file app/public/index.php to your server document root

and make the following changes Change ''' require DIR .'/../vendor/autoload.php ''' to ''' require DIR .'/app/vendor/autoload.php ''' Change ''' require_once DIR .'/../bootstrap/app.php ''' to ''' require_once DIR .'/app/bootstrap/app.php ''' In app/server.php make the following changes

Change ''' require_once DIR .'/public/index.php ''' to ''' require_once DIR .'/../index.php '''

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM