I created a new web site using Grav. The old site has pages that had to be accessed using urls ending .php
The url /somefolder/somepage.php just gives me “File not found”. It does NOT lead me to the built-in Grav error page.
I disabled the error plugin of Grav so it does not get in the way.
How do I rewrite any url ending in .php to the homepage /
Also, how can I redirect any 404 error to the home page?
So you wish to redirect
oldpage.php to the new page address?
Actually I would like to redirect any non existing page to the homepage (/)
I had the error page turned on at first.
But… it would not catch the .php URLs.
The browser would just say “file not found”
Could you give some guidance on how to set the 404 Route to /
I did try a few things but what I tried, didn’t work.
Did you set up everything as I asked in above post?
Please, set the Error plugin as shown on the screenshot, and let me know. In my case it redirects all of the pages, those ending with .php as well. But you have to enable the plugin, and point it to the custom route, in this case
/ (enter only slash where it asks for
It still doesn’t work?
Let me set it up, just a few minutes.
I’m sorry but it does not work.
Error plugin is turned on.
WIthout .php the error page gets called
$page = $pages->dispatch($this->config->get(‘plugins.error.routes.404’, ‘/error’), true);
$page = $pages->dispatch($this->config->get(‘plugins.error.routes.404’, ‘/’), true);
I replaced the content of error.md with the content of the home page.
That solved one part of the problem.
Any non-existing page not ending in .php will show the home page.
But URLs ending in .php will still give “file not found”
Funny because any other extension will get you to the error page.
Extensions like .asp or .xml work as expected (redirect to error page)
Well, it’s the plugin code, I wouldn’t touch it if I were you
Okay, are you using Admin panel at all? Or are you making all changes on the files?
I did change the files but it would be better to use the Admin panel.
I just don’t know how to fix my problem using the admin panel.
I restored the changes I made to the plugin. I just replaced the content of error.md with the content of my homepage.
That solves one part of my problem.
Now only the .php error is left.
Okay. Go to this address:
Do you see screen similar to one pasted by me in a post above?
Yes, I see the same screen. It says enabled.
Okay. Beneath the ‘enabled’ part, you have a field to enter ‘404 Route’, yes?
In this field, enter only the
/ symbol, nothing more, then save it
Sorry, had to create a new account. New users can only send 25 messages
Okay, that worked.
So the URL http://earthfather.eu/nothing brings me to the home page, great.
But http://earthfather.eu/nothing.php still gives me an empty browser screen with “File not found”
Please try the .php link
Could it be caused by the way Grav is setup?
I am using a Docker container so I did not have to install PHP and other stuff I don’t know anything about.
I’m using this Docker container: