For testing purpose I have Installed fresh Laravel-7 and also installed joedixon/laravel-translation package, all are working fine.
After that I have changed root directory and others (I have to change for implementing the Translation in another running project which root directory like that)-
Change things are-
Moved index.php into root directory, ex: myproject/public/index.php to myproject/index.php
Move .htaccess into root directory
In index.php, changed-
require __ DIR __.'/vendor/autoload.php';
and
$app = require_once __ DIR __.'/bootstrap/app.php';
And for Translation I added the /public/ for the path of css, js in resources/views/vendor/translation/layout.blade.php
And now all are working but when I try to update the translation file, It throws an error showing the requested url is not found.
Everything else seems to work fine expect for updating the translations.
How to solve ?
Screenshot attached.
enter image description here
i didnt work with this package before but i have noticied a double slash // in your requested url you trying to post to ( in the screenshot ) so that could cause a 404 since there is difference between
http://localhost/cartpro_language_test//languages/bn
and
http://localhost/cartpro_language_test/languages/bn
make sure its accesible in your routes check php artisan route:list
by default its accessible under /languages not /cartpro_language_test/languages so verify if there is any other changes you made that cause the url to be different than the one sat up
i did the exact same modifications and its working for me
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.
On a fresh Laravel 8 installation I follow these steps:
php artisan storage:link
Inside /public/storage/ I create folder images/ and inside I paste an image called picture.png
In web.php I define a route like this:
Route::get('/picture', function(
return response()->file(Storage::url("images/picture.png"));
))
However, if I visit this route in browser, the picture is not shown and the following error is thrown:
Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException
The file "/storage/images/picture.png" does not exist
It works only if the url inside response()->file() is prefixed with ./ indicating the current directory like this:
return response()->file('./'.Storage::url("images/picture.png"));
I don't think it is a good idea to work with relative paths locally, the Storage and file methods should handle this. Maybe it is even an issue with the framework.
Any ideas how to go around this hack?
I think you didn't configure the local driver check the documentation https://laravel.com/docs/8.x/filesystem#the-public-disk and look for local driver.
If you configure it right it should return the "/" that you're adding manually.
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 am encountering a problem with wordpress. Until now I have set up quite some installations, but this time I get a weird error.
I installed WP on a remote Server in an existent database, that already contains 2 wp-installations with different table-prefixes. The new installation of course got a differing prefix.
The new installation was made in a subfolder on the server:
www.theUrl.com/wp/<wp_files...>
The URL directs to a subfolder ("my_new_site" in the example underneath) on the server. Inside this subfolder I created the folder "wp" where I put all the wp-files.
root-dir
|-> existing_wp1
|-> existingwp_wp2
|-> my_new_site
|-> wp
|-> <wordpress-files...>
The whole installation prosess of wp worked as usual and I got redirected to the login-page. But after logging in, i get the Error:
Not Found
The requested URL /wp/wp-admin/ was not found on this server.
phpMyAdmin shows me, that the tables with the specified prefix were created. Trying to open the index.php-file directly is causing nearly the same error, mentioning, that "/wp/" was not found.
However I can access wp-login and readme.html. FileZilla is showing me, that all files are correctly uploaded.
I absolutely have no idea where to start searching for a solution, because the directories are evidently existent.
EDIT: changed the url to: www.theUrl.com/wp/ and added information on the directory-structure
I have a symfony2 project that somehow was running fine while it was outside the public_html directory, but now it's not working (the path is not allowed anymore, apparently).
Now I need to move the symfony2 directory into public_html, but when I do, the website is still not working (the page is blank).
I modified app.php so the include path is the correct one, and I also modified the projectConfiguration class so it has the right WebDir. What am I missing?
alternatively, how can I make it work outside the public_html directory?
for the record, I'm completely new to symfony.
The cache was the culprit.
I cleaned symfony's cache (removed all the contents residing in the cache folder) and the website came back to normal.
thanks to fos.alex for the comment/answer.