Anytime I add a new CMS page from the admin dashboard, it Magento generates a no-route 404 page not found error. After days of meticulous troubleshooting across multiple installs and versions of Magento 2.x.x, I鈥檝e discovered a one way to get the pages to load.
After creating the page and saving it from cms/page/new.
I have to go back to /cms/page/index, select layout, assign a new layout (like changing from 2 columns with right bar, to 1 column), and Save. Then select Action > View. Only after following that specific sequence will any CMS page load.
I鈥檝e tested this in both developer and production modes. Currently tested this on Magento v2.1.10-rc2, Ubuntu 14.04, Nginx, and PHP 7.0.6.
Magento v2.1.10-rc2, Ubuntu 14.04, Nginx, and PHP 7.0.6.
develop
branch on a Ubuntu 14.04 LEMP stack. Save and view.
Load the page
Magento no-route 404 Page Not Found.
Experiencing the same issue here. Visiting _cms/page/view/page_id/{page_id}_ also doesn't work so it's not a rewrite problem.
A little bit of digging around shows that the new page somehow is only added to the cms_page
table but not cms_page_store
which means it doesn't belong to any store so it won't load. If I manually add the relationship in cms_page_store
and refresh the page cache, the page loads.
So...is it Magento at fault here or is it my setup?
(2.0.1-rc3, ubuntu 14.04, nginx, and php 7.0.7)
Okay more info. This is only happening in single store mode for me. Disabling single store mode forces you to define the relationship by selecting a view when adding a new page (all store views, default store view, etc). Therefore it updates the cms_page_store
table fine.
Is this supposed to happen in single store mode? Or am I missing a setting somewhere?
Same bug here with single store mode on.
same bug but in multi store mode
Same issue here with 2.1 CE using single store mode.
This worked for our 2.1 CE installation.
same problem
Unable to save page edits, occurs when using the alignment field. 404 page, if I don't align anything it'll save.
having same issue of being able to save pages edits. get 404 when pasting in large bits of content but will save if I break it up into smaller bits. same content...just split up. 404 on frontend for the url. Magento 2.1.0 single store mode. the admin 404 was due to a mod security setting on the nexcess host. still trying to figure out the frontend 404.
taking this out of single store mode resolved it for me but only after doing what @michaelsalafia suggested which is change the layout of your page, save it, view it, change it back.
Can confirm the bug, have to do what @3dcauldron suggested to solve.
@3dcauldron Thanks, it's working for me.
Still here in 2.1.2
I have the same issue when I am trying to save a CMS block or page on 2.1.2. Does anyone have a fix for this?
just what @3dcauldron said to do an immediate fix but then cannot run in single store mode.
@rosandrest thanks, but that didn't work for me
I have the same issue. Earlier CMS pages are working fine but now if i create a new CMS page then it gives 404.
I check in the database. New page is in cms_page table but link with cms_page_store. How to solve this?
I made an alternative solution for this
4 months later, this is still open.
~ I solved this and many other bugs by switching back to magento 1
I can't even assign a store view to CMS because is throwing that 404 error on Save. It might be related to a similar issue I had, when saving content Blocks and was fixed by following these steps: https://github.com/magento/magento2/issues/2966#issuecomment-237814927.
Ma kore em ze?
@magento-team This is due to the Magento\Cms\Model\ResourceModel\Page\Relation\Store\SaveHandler implementation. It relies on the form
Judging by the code in the saveHandler there is meant to be a fall back using $entity->getStoreId() where stores is not populated, but this is not set either. So whenever you save a new CMS page the $insert var is set to array_diff([], []), hence no insert takes place on the cms_page_store table and your page is not accessible on the front-end.
$newStores = (array)$entity->getStores();
if (empty($newStores)) {
$newStores = (array)$entity->getStoreId();
}
...
$insert = array_diff($newStores, $oldStores);
if ($insert) {
// insert in to the cms_page_store table
}
Went to fix this today and found the issue is resolved in the develop branch upstream. CMS is now using it's repository to save too. Fingers crossed for this being closed on next release then!
same issue in version 2.1.3 with single store mode.
adding a row manually for not founded cms page (cms_page table) to cms_page_store table resolve this. But i think it is not the right way. Still it is a bug
Magento 2.1.3 multistore with two additionals subdomains, page error not found 404 works fine in main domain, but not in two additional subdomains just recive this error:
Fatal error: Uncaught Magento\Framework\Exception\LocalizedException: Area code is not set in /home/salelso1/public_html/vendor/magento/framework/App/State.php:139 Stack trace: #0 /home/salelso1/public_html/vendor/magento/framework/Session/SessionManager.php(173): Magento\Framework\App\State->getAreaCode() #1 /home/salelso1/public_html/var/generation/Magento/Framework/Session/Generic/Interceptor.php(24): Magento\Framework\Session\SessionManager->start() #2 /home/salelso1/public_html/vendor/magento/framework/Session/SessionManager.php(130): Magento\Framework\Session\Generic\Interceptor->start() #3 /home/salelso1/public_html/var/generation/Magento/Framework/Session/Generic/Interceptor.php(14): Magento\Framework\Session\SessionManager->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Framework\Session\Config), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(M in /home/salelso1/public_html/vendor/magento/framework/Session/SessionManager.php on line 175
I can confirm the same issue in 2.1.3. Adding CMS pages with single store enabled causes a 404 on that page.
Same issue in 2.1.4. It's returning 404 page, but it's not the same error page as I have styled, it just says: 404 error: Page not found. where mine have header and footer visible as well
Is there a way to remove store related records from database for using single store mode ? For me, some other single store related problems fixed by removing other store data.
hello @michaelsalafia, thank you for reporting the issue, but I couldn't reproduce it. Could you please provide more details?
I try next variations on LEMP stack:
Problem Still present in Magento 2 v2.1.6
hi @jaydigital ,
I would suggest @rosandrest solution (worked for me on more that one site on different servers).
Could be just a mod_security issue : contact your hosting provider, provide step to reproduce and the page url where of the 404 page.
They should be able to easily tackle it.
cheers!
Thanks romeof1980,
I've already got them working on it.
Apparently, the page starts working if you change the URL key in the quick editor that appears when you click the page line in the list of pages.
Yes it does because with mod_security rules are set in order to block some URLs. I'd advise to inform your sysadmin or if you take care of the server directly double-check mod_security rules.
cheers!
This is still present on 2.1.7. It is quite disappointing that a bug as severe as not being able to add new pages in single store mode has gone unaddressed for over a year now.
Like @rbostan mentioned, if you want to stay in single store mode the entire time, a functional workaround for the time being is:
cms-page
table, and notice it is missing in cms-page-store
. Create a new record in cms-page-store
for your new page, where page-id
is your newly created page and store_id
is simply 0
.When you navigate to the URL, it will now load instead of presenting a 404 as it did before. As far as I am concerned, this is a bug and it is not practical to expect an average layman end user to start creating sql queries to get pages to load as expected.
Same problem experienced here! Magento 2.1.3
A nice workaround for people who want to stay in single store mode.
@michaelsalafia Solution given here works on When Single Store Mode is enable or Disabled.
@michaelsalafia, thank you for your report.
The issue is already fixed in 2.2.0
Reopen the ticket same issue is verified in mage 2.2.1 on a single store, don't save any block
It looks like I can get to the page by adding /index.php/ eg: www.magento.com/index.php/mycmspage
I'm seeing this issue on 2.2.9.
Most helpful comment
4 months later, this is still open.
~ I solved this and many other bugs by switching back to magento 1