OctoberCMS 404 page custom URL for my 404 page - php

I am using OctoberCMS Static Pages plugin in which I have created a 404 page with my custom URL something like this http://localhost/my_website/home/content/error404 .
When I open this page, its working fine but when someone types URL which is not exists something like this http://localhost/my_website/whatever, it is not showing the 404 page which I have created.
Can someone guide me how can I set this page as my default 404 page?
Also I have created a partial to set the content and I dragged and dropped this snippet into this static page.
Any suggestion or thoughts?
Thanks

You just need to create a page with the "URL" of the page in October set as /404 and October will use it for 404 errors.
You can also set a page with a URL of /error to handle "500 Internal Server Error"

Related

How to get the link that the user tried to visit, from a 404 custom page made in php

I have a website in different languages, thus I want to show a custom 404 page for each language.
Is there a way to find out which page the user tried to visit (that didn't exist) in order to find out which language I should display the 404 page?
The web server is Apache.
Thank you very much.
if you use .htaccess file for redirect then add
ErrorDocument 404 /yourdir/error/404page.php
then use request uri in session which stores the page user are visiting i.e.
$_SESSION['req_uri'] = $_SERVER['REQUEST_URI'];
then redirect user to $_SESSION['req_uri'].
where $_SESSION['req_uri'] is the page user trying to access.

wordpress does not give 404 error

Hello all!
I want to know that when we click on menu item in wordpress website, It takes us to the url associated with that link but how wordpress does that! I mean, the following url :
http://www.example.com/this-is-another-page/
I know wordpress will get the data from database but How wordpress will handle this url because the page is not available it should give 404 error
please tell me.
I am learning php.
WordPress handle this page by checking few things.
WP Check the credential by POST ID
First it's check the POST Exists or not? If not published then it gives you the 404 error.
WP check whether the post is published or not? If not published then it gives you the 404 error.
Then it's render the information from the database.
When you create a link that page link is added in the database. If the page is not created and you put a link that not exist, wordpress will bring you up a page error template.

404 Page is generated instead of proper 301 redirect to new post

I changed permalink from /%postname%-%post_id%/ to /%postname%/ only. But the problem is that I can't get any method to redirect 301 old permalink to new one.
I searched google and found this plugin which redirect the old permalink to new one. When I check the HTTP Response Header, it also shows the old page is being redirected to new one but actually in the content it shows 404 page. Here is the example page.
Even when I try to fetch the page in Google webmaster tools, the bot fails to fetch the old page.
Is there any way to fix the problem??
Quickest way is just add some redirect into your .htaccess file, if you use Apache server.
You can easily populate the url list for your legacy links by write some sql query.
.htaccess
# BEGIN FIX URL
Redirect /my-sample-post-100 /my-sample-post/
Redirect /my-2nd-sample-post-101 /my-2nd-sample-post/
...
etc
# END FIX URL

wordpress not able to find homepage

This is the website url www.iaspirant.com .
So this will redirect to 404 page. Now the strange thing is when I do a login from wordpress wp-admin and then try to open the website then homepage gets load successfully.
So this happens only when a user is not admin.
Now in order to resolve that I googled lot and tried various approach but with no success.
tried to add 301 redirection in 404 page so that it will redirect to home page but this creates a loop
Try to delete .htaccess file but no difference
Try to change the theme to ensure whether its error in code but no success
If any one can suggest me anything then it will great help.
Try goto to /wp-admin/options-reading.php
And setup Front page displays as static page or post.
Do you have installed any maintenance plugin?
Did you check the permissions? try a permissions plugin
Go to settings->reading and see if you have set Front page displays your latests posts and not a static page
You just made a mistake in Param links:
Change your home param link to http://iaspirant.com/?page_id=428 and
then it would definitely it will wok.
Check also your static page in customization
go to apperence-->themes-->customization and set static page as your home page.

How can I show a page that not exists with PHP?

I have a website that show information about a shop online. I need following:
When you type example.com/shop/name-shop, this should show the name-shop page.
I'd like only have the file example.com/shop.php which show the information of shop based on the URL. I don't like use example.com/shop?name-shop.
Is this possible or I need to create one file to each shop? I tried to do this with an error page and a header location and works fine but in the url show example.com/shop instead of example.com/shop/name-shop.
Thanks.
EDIT:
I'm using the .htaccess in Apache with ErrorDocument 404 /error404.php In the file error404.php I've a if to check if url is http://example.com/shop/* When the url contains /shop/ redirect with header ("location: website") to the correct shop and works. But in the url in browser only show example.com/shop instead example.com/shop/name-shop. Obviously because i'm redirecting to shop.php
Depending on the web server you are using, you will need to use rewriting rules (mod_rewrite for Apache) or 404 pages to show custom content on each URL using only one PHP file.
I'd recommend you to use Symfony2. You can define routes with placeholders and you have a FrontController, which would correspond to your shop.php file.

Categories