dimanche 23 juillet 2017

Laravel unable to load resource images/fonts in XAMPP

I am trying to deploy my Laravel project in XAMPP. After accessing my URL, it loads html/css and js but didn't return images and fonts.

CSS/JS/images and fonts files are located in public dir.

As I check my console, it returns 404 error with incorrect path:

http://localhost/fonts/icons.woff2 [HTTP/1.1 404 Not Found 4ms]
downloadable font: download failed (font-family: "Icons" style:normal 
weight:normal stretch:normal src index:1): status=2147746065 source: 
http://localhost/fonts/icons.woff2?af7ae505a9eed503f8b8e6982036873e

I checked other solutions for .htaccess in public and root directory. I rename my server.php in root dir to index.php.

Application's .htaccess files:

public/.htaccess

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

/.htaccess

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]

RewriteCond %{REQUEST_URI} !(\.css|\.js|\.png|\.jpg|\.gif|robots\.txt)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(css|js|images)/(.*)$ public/$1/$2 [L,NC]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire