guys I have a laravel project and its working fine. Every time I start the project by typing the command php artisan serve
and then by typing the url localhost:8000
in my browser. But now I want to start my project only by typing the url localhost/projectname
.
So I did a little bit of digging and found out a way to do this, I made it possible by changing the server.php file from root directory to index.php and copying the htaccess file from public folder to root directory`. This way my browser loaded only html file or php file but css files and js files were not loaded so I had to modify there link on the blade file for example:
Previously a style.css file was linked as:
<link rel="stylesheet" type="text/css" href="{{asset('front_end/assets/css/style.css')}}">
Now I link the same style.css file as below:
<link rel="stylesheet" type="text/css" href="{{asset('/public/front_end/assets/css/style.css')}}">
And It works fine.
But now I have found another problem, I have stored some files (images) in the the storage/app/public/myfolder
directory so to access the files I had to use the command php artisan storage:link
command and to access the files(images) from above mentioned directory from blade file I use the code below:
<img src="{{$url = Storage::url('myfolder/'.$company->logo_name)}}">
This code did worked only worked when I used to start my project using php artisan serve
command. Now I its not linking so what should I do? And also can you guys tell me the way that I changed the server.php
file to index.php
is the right way or not? And what you guys do in your real projects?
Thank You.