'Laravel url() function returns public two times
I am using Laravel url() function to get website base url, but it returns public two times I don't know where I am doing wrong? Any help would be highly appreciated.
Here is my code.
<link rel='stylesheet'
href='{{ url('/') }}/js/background-check.min.js' type='text/css'
media='all' />
Here is the output I get: https://www.example.com/public/public/js/background-check.min.js
It should look like this: https://www.example.com/public/js/background-check.min.js
Solution 1:[1]
you need to not include public folder in the url , to do that
if you are using Apache
create .htaccess file in your root like this:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,QSA]
if you are using Nginx you can look at the following Nginx config:
server {
listen 80;
listen [::]:80;
root /var/www/html/quickstart/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name example.com www.example.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
