im new in laravel so im just try to run laravel without php artisan and read much topics about run laravel without php artisan but the main problem is the main route (/) is working and run (home view) but other routes like (/about) in web file doesnt work. so how can i run other views via routes (web file)?? i tried many ways for run laravel without php artisan but im stuck in this part routes. without routes, laravel is completely useless. i moved index.php from public folder and .htaccess to the root folder for run laravel wihout php artisan like this:root folder laravel
and this my index.php so i changed it to run from root not public folder:
index.php file
and .htaccess:
.htacess file
and finally this is my web file which is my routes:
web.php
when i set routes about and try to go to that, the error 404 is shown up: error 404 /about route
so how can i set routes and actualy the main problem is how can i request and Recieve urls from root without php artisan. and another way that i tried is rename server.php to index .php and i could say none of this ways are working. it just show the root home page not working for other routs. thanks
Related
I have a laravel application that I made changes to the folder structure, I have been working with laragon and everything works fine but on my local environment and live server.
However, when i user php artisan serve, the generated url doesn't load assets in the public folder.
E.g
https://livewebsite.com // [live server] works.
https://myproject.local // [laragon] works.
http://localhost/myproject // [laragon /xampp] works
http://127.0.0.1:8000 // artisan [doesn't load assets, assets in the public directory returns 404
//e.g http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css would return 404
Changes I made,
|-core
|-public
|-.htaccess
|-index.php
I have moved all laravel core folders and files to the core folder,
moved the .htaccess and index.php to the root directory.
From my debugging so far, I understand that laravel built in server redirects requests to the public folder where the index.php file is located.
What changes can I make so that the request is not sent to the public folder,
i.e http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css should just be allowed to be without be redirected.
The entire thing works on various environments except when I'm using laravel built-in PHP server with the artisan command.
EDIT
Folder structure
|-project
|-core
|-app
|-bootstrap
|-config
|-database
|-lang
|-etc
|-public
|-assets
|-test-folder
|-img.png
|-.htacess
|-index.php
in this setup, laravel base_path() is project/core . This where all laravel core files and folders are stored.
Now I have folder test-folder with an image img.png . If i go to http://localhost/project/new-folder/img.png it will return the image but if i go http://127.0.0.1:8000/new-folder/img.png will return 404. If i use a live server and go http://livewebsite.com/new-folder/img.png , it loads.
I can't comment due to reputation, but what you're doing might be unsafe!
This way all your project files will be public, which can expose credentials and exposes Composer packages to the public as well. This means any PHP file in any Composer package can be executed, which can lead to remote code execution, which has happened before here and is described here.
I just tried a url on my live site and saw this:
if ı write my url artisan, for examlple oguzkurukaya.com/artisan
it shows artisan folder or downloads it. How can disable this?
You should set the root path of your website to public folder - which contains index.php file.
I am creating an application to be hosted on a server, and I used .htaccess however the first page that load which is usually the login screen(whose path is in my resources folder)has change to the public folder and I click anywhere else as everything is linking to the public folder, which is not right as its supposed to be in the resources folder... the app works fine, its just the routing that's giving me an issue so when i click anywhere else it says, 'the requested url can not be found on server'
I also tried putting the view folder into the public folder and routing there
my homepage is set to:
Route::get('/', function () {
return view('auth/login');
});
but this gets an error when moved to the public folder, the error reads,
InvalidArgumentException
View [auth.login] not found.
Clear your caches and restart your server:
composer dump-autoload;
//---Flush the application cache
php artisan cache:clear;
//---Remove the configuration cache file
php artisan config:cache;
php artisan config:clear;
//---Remove Routes Cache
php artisan route:clear;
Hello everyone i am new to laravel and i hope someone can help me about my problem. I created a laravel project. After that I import it to cpanel using softaculous. Then, I made some changes base on what i research in the net to avoid showing important file like .env . I created a folder relative to public_html, let say the folder name is 'tamangbilang' where i put almost all of my code except the index.php. Inside my public_html folder, I have another folder named as 'tamangbilang' where my index.php resides. I have followed this instruction https://dev.to/pushpak1300/deploying-laravel7-app-on-shared-hosting-hostinger-31cj the only difference is that I put another folder inside public_html.I also did some changes on the index.php code
require __DIR__.'/../../tamangbilang/vendor/autoload.php';
$app = require_once __DIR__.'/../../tamangbilang/bootstrap/app.php';
Everything is working fine on my login page(my first page) but when I try to login, an error occur.
The requested URL was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
It seems like the connection between routes was lost. I did further testing and I notice that the code is working well only if there is an index.php, before the route in the url. example
http://my-sample-domain.org/tamangbilang/index.php/login
P.S. I don't have access for ssh.
go to bootstrap folder & open cache folder then delete config. after that please check your routes this error basically arises due to routes not found for that go to your project installed on local and write php artisan route: list check if the route is present or not.
I have a laravel project which I run from my local apache server directory.
The link for accessing this project is
www.localhost/project.dev/public/index.php
And I have a navigation menu
After I have set the APP_URL in .env file to
http://localhost/blog.dev/public/index.php/
I get no problems while navigating through the About and Contact pages in the project but when I access the Home page the browser goes to the
http://localhost/
but not to the
http://localhost/blog.dev/public/index.php/
How can I fix it? Here are my routes:
Route::get('/', 'PagesController#getIndex');
Route::get('about', 'PagesController#getAbout');
Route::get('contact', 'PagesController#getContact');
I think the best way is to setup a vhost in apache. if you want to work like this in your .env set the APP_URL= http://localhost/blog.dev/public/
Run php artisan serve in command line. The laravel buil-in server will active. And you will able to access your laravel application using correct url as like http://localhost:8000 try this and let me know if you have any problem.