Cakephp Controller index link not working without trailing slash - php

(First question on stackoverflow. Tell me what I can do better)
When accessing controllers index pages it is not important if i type a trailing slash or not. Cakephp redirects both versions automaticaly.
Now my 'videos'-controller is behaving weird. It worked fine 2 days ago but now I cannot accessed it without a trailing slash.
Examples:
domain.com/users/ -> Working user index site
domain.com/users -> Working user index site
domain.com/videos/ -> Working videos index site
domain.com/videos/add/ -> Working videos add site
domain.com/videos/add -> Working videos add site
domain.com/videos -> Domain redirects to domain.com/webroot/videos/ and a MissingControler Exception is thrown. The error message is:
Error: WebrootController could not be found.
In the case you tried to access a plugin controller make sure you added it to your composer file or you use the autoload option for the plugin.
Error: Create the class WebrootController below in file: src/Controller/WebrootController.php
I have not defined any Routes for Videos. I made no changes to the htaccess files.
Can anyone help me with this error? Should I post additional source code?

It's because you have videos folder inside your webroot directory. Please change folder name or apply a route.
Thanks,

Related

joedixon/laravel-translation not working during update

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

Error 404 after migrating laravel 8 to a shared host

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.

Deploy Laravel in var/www/html

I have the following file structure on my server
/var/laravelapp -> this is the entire laravel project.
/var/www/html/eduapp - > this is the public_html folder which has a folder called eduapp with the public contents of laravelapp.
The login register and home page work
https://example.com/eduapp/
when i click on the other buttons in the homepage the url becomes https://example.com/routename therefore giving an error
if we manually add eduapp in the link eg. https://example.com/eduapp/routename it works!!
any suggestions or solutions?
so these are the things that made the app work
Changed APP_URL to example.com/eduapp.
Changed back button hrefs to href='../routename'.
Created Symlinks for public/img and storage folders.
Removed Slash from href routes.

Unable to access controllers of codeigniter which is installed under a wordpress site

I have a Wordpress site. So all i wish is to fetch the information from those database tables and create my own custom API's. For that i opted CodeIgniter Framework.
The file directory system looks like this in my FTP
My codeigniter files are placed in apps folder
The problem is the pages are not loading, It always returns 404 Error
or No Input file specified/found etc.
I tried changing .htaccess file but no luck.
But if i specify
applications/apps
i.e controller/method in default_url in routes.php it works fine.
and if i click on the Hyperlink, i am trying to load another view or call another View(a web page) but this returns 404 error page not found.
What might be the reason behind this.

CakePHP working on local but can't get it work on production

I have an issue making my cakephp project work on my shared hosting server.
I followed all the needed steps so it can work on local, and it's working. Once I upload on the server, in a specific domain name, only the homepage works, once I want to call another controller, i get the "404 - File or directory not found." error.
the project is hosted at : fme.tahrijouti.com. the domain redirects to the webroot folder in the cakephp structure.
My controller is : posts. I can make it work if I change the URL by specifying the controller & action, you can see it here.
I have checked and the rewrite module is on.
Can you please help me with that ?
Please have a look on CakePHP default routing. And don't forget to fix all your links.
Your links should have proper addresses. Just look on your Posts's link. These are like this http://fme.tahrijouti.com/index.php/posts/posts/view/2 but it should be http://fme.tahrijouti.com/index.php/posts/view/2. Remember after your host name there exist controller then a function of that controller then argument of that function like this: [host]/[controller]/[function]/[argument1]/[argument2]. Hope it helps. I think you can read cookbook another bit as most things are clear there from my experience.
As I don't have your codes of controller I cannot say more.

Categories