Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Page not found not giving 404 status code #767

Closed
tostasqb opened this issue Jan 29, 2018 · 2 comments
Closed

Page not found not giving 404 status code #767

tostasqb opened this issue Jan 29, 2018 · 2 comments

Comments

@tostasqb
Copy link
Collaborator

The page not found is giving a 200 status code instead of a 404

@brian-kephart
Copy link
Collaborator

Are you setting the 404 page in your site settings? This happened to me as well when I set a 404 page in my site settings. To work around it I added app/apps/themes/my_theme/views/camaleon_cms/404.html.erb and disabled the redirect in site settings.

Basically, the default 404 behavior is correct, but selecting a 404 page in your site settings causes the CMS to treat it as a redirect. See here.

@tostasqb
Copy link
Collaborator Author

Thanks for the workaround @brian-kephart. Nice to know.

Still, being constructive, I don't think that setting a page not found on site settings (that I did) should change the status of the page. That is just the definition for witch page to use as "page not found"...should always give the correct status code.

Haven't tested any code solution here but I think one of two scenarios would be appropriate:

  1. Change the line to add a status
    redirect_to page_404.the_url, status: :not_found
  2. Instead of redirecting, because it previously sends a 3XX code, just render the setting page if set by the user or the 404. Any of the two with the status :not_found

Setting the correct status code also avoids SEO and crawling problems from Google that currently catches "Soft 404" issues.

jpac-run pushed a commit to shermanstravel/camaleon-cms that referenced this issue Jan 31, 2018
…ser, and with the correct status code, in this case the 404 Not Found. Resolves owen2345#767
cyanglee added a commit to cyanglee/camaleon-cms that referenced this issue Mar 21, 2018
* upstream/master: (166 commits)
  Fix 'before_upload' hook when uploading to local filesystem
  - Fixed settings template
  - Fixed hardcoded them settings template file name - Fixed translation for content tabs
  Created endpoint on frontend_controller, to render a page not found,  to take out access to some page by the user
  Fixed match typo Release 2.4.5.3
  Added index to menus  (admin)
  fix post_order when no records
  767: refactored render_post method. Added a status parameter to the method signature, to be used on the options hash of the post render, and send the status when rendering the post.
  Created a new method that renders a custom 404 page, defined by the user, and with the correct status code, in this case the 404 Not Found. Resolves owen2345#767
  Fixed break line process for tinymce
  calc post order for persisted record only
  Skip forgery check on .js files in /assets
  fix post order bug when old posts are deleted
  update will_paginate column distribution
  Slugify folder name when creating
  Let a hook override the ability to see drafts
  fix typo error
  generate random character when slugify empty
  fix post tag created without parent_id bug
  Updated version file
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants