Returnerar dina WordPress posts ett 404 error på din website?
Detta error inträffar när du kan komma åt din WordPress admin area och blogg, men när du försöker öppna ett inlägg, kommer du att se ”404 Not Found”.
I den här artikeln kommer vi att visa dig hur du fixar WordPress-poster som returnerar 404 error.
Varför returnerar mina WordPress-poster ett 404 error?
Det finns flera anledningar till att dina WordPress-poster kan visa ett 404 ”Page Not Found” error. Dessa kan inkludera:
- Konflikter med plugin eller theme: Ibland kan tillägg eller teman som du har installerat på din site störa hur WordPress hanterar permalänkar. Detta kan leda till brutna links och 404 error.
- Problem med customize-kod: Om du har addat custom code till din website kan det finnas error i koden som påverkar permalänkar eller orsakar andra konflikter, vilket resulterar i 404-fel för dina posts.
- Issues med din .htaccess-fil: Filen .htaccess spelar en roll för hur WordPress strukturerar URL:er. Om den här filen är skadad eller saknas kan det leda till 404 error för dina posts.
Med detta sagt, låt oss titta på hur man fixar WordPress posts som returnerar 404 error. Du kan använda länkarna under för att hoppa direkt till olika lösningar:
Vill du inte fixa 404 error själv? WPBeginners Pro-tjänster kan hjälpa dig! Med vårt prisvärda Emergency WordPress Support kan du anlita experter för att fixa 404 error, trasiga links, redirect issues och mycket mer. Sluta stressa över WordPress-problem och få dem fixade! Schemalägg tjänster för akut support för WordPress idag!
Video Tutorial
Om du föredrar skriftliga instruktioner är det bara att fortsätta läsa.
Metod 1: Kontrollera för Plugin eller Theme Conflicts och Custom Code Issues
Ibland kan plugins, teman eller customizer-kod som du har addat till din WordPress-site störa permalänkar eller orsaka konflikter, vilket leder till 404 error. Vi har till och med upplevt det själva när vi testar tools på vår demo-site.
Ett sätt att lösa detta problem är att tillfälligt deactivate tillägg. Tillägg kan ibland störa hur WordPress hanterar links.
När du har deaktiverat plugin-programmen kan du reaktivera dem ett efter ett och samtidigt kontrollera om 404 error återkommer efter att du har aktiverat varje plugin. Om error dyker upp efter att ett specifikt tillägg aktiverats kan det vara den skyldige.
You can then search for solutions related to that plugin or contact the plugin developer for support.
På samma sätt kan ditt WordPress theme orsaka konflikten.
För att kontrollera kan du tillfälligt byta till ett standardtema för WordPress som gillar Twenty Twenty-Three eller Twenty Twenty-Four. Allt du behöver göra är att gå till Appearance ” Themes och klicka på ”Activate” på ett standardtema.
Om 404 error försvinner med standardtemat tyder det på en potentiell konflikt med ditt nuvarande tema. Du kan då försöka felsöka temat eller överväga att använda ett annat tema.
Du kan kontrollera vårt expertval av de mest populära WordPress teman för rekommendationer.
Om du senaste har infogat code snippets på din website kan det finnas error i koden som orsakar 404-felen. Ta en close titt på koden som du har add to och se om du kan identifiera några misstag.
Det säkraste sättet att add to code snippets till WordPress är med WPCode plugin. Detta plugin låter dig insert custom kod utan att direkt arbeta med theme-filer, vilket minskar risken för att bryta din website.
Dessutom, när WPCode upptäcker ett error i din kod, kommer det automatiskt att deactivate snippet och be dig att kontrollera det. Du kan också använda testläget för att kontrollera om din kod fungerar innan du skickar den till din live website.
Om ingen av dessa lösningar fungerar, gå vidare till nästa metod där vi troubleshootar dina permalänk-inställningar.
Metod 2: Fixa dina permalänk-inställningar
WordPress-poster kan returnera 404 error på grund av problem med omskrivningsregler i din .htaccess-fil. I de flesta fall kan du fixa problemet genom att updating dina permalänk-inställningar.
Gå bara till Settings ” Permalinks i din WordPress-admin och klicka på knappen ”Save Changes”.
Det finns inget behov av att göra ändringar i själva inställningarna för permalänken. This will update your permalänk settings and flush the rewrite rules.
I de flesta fall fixar den här lösningen WordPress posts 404 error. Men om det inte fungerar för dig, behöver du förmodligen updating din .htaccess-fil manuellt.
Metod 3: Update av .htaccess-filen i WordPress
Innan du börjar, se till att säkerhetskopiera din WordPress.htaccess-fil först. Om något går fel kan du enkelt återställa originalfilen.
Nu måste du ansluta till din server med hjälp av en FTP-klient som FileZilla eller File Manager-appen i din WordPress dashboard.
Därefter måste du hitta och redigera .htaccess-filen, som ligger på samma location som foldrar som gillar /wp-content/ och /wp-includes/.
Högerklicka bara på filen och välj ”File permissions”.
Du kan göra filen skrivbar genom att ändra dess behörighet till 666.
Du behöver bara enter ”666” i boxen ”Numeric value” och sedan clicka på ”OK”.
Sedan måste du upprepa stegen i den första metoden i vår tutorial. När du har gjort detta, glöm inte att ändra behörigheterna tillbaka till 660.
You can also edit the file and add code to it.
När du har öppnat .htaccess-filen med en textredigerare infogar du helt enkelt den här koden:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Metod 4: Kontakta din hosting provider
Om ingen av lösningarna ovan har fixat WordPress-poster som returnerar 404 error, rekommenderar vi att du kontaktar din WordPress hosting provider. Det kan finnas ett error hos dem, eller så kanske de kan hjälpa dig att troubleshoota problemet.
Vänligen se även vår guide om hur du ber om support för WordPress på rätt sätt och hur du får det.
Metod 5: Fix WordPress Posts Returning 404 Error på lokala servrar
Om du använder en lokal server för teständamål måste du aktivera mod_rewrite i Apache-konfigurationen på din MAMP-, WAMP- eller XAMPP-webbplats.
This will allow WordPress to generate clean URLs and prevent the 404 error for posts and pages on your local server.
Hur du gör detta skiljer sig åt beroende på vilken plattform du använder. Personer som använder XAMPP kan öppna sin panel och klicka på knappen ”Config” inom Actions. Välj sedan ”Apache (httpd.conf)”.
Därefter måste du hitta den här raden #LoadModule rewrite_module modules/mod_rewrite.so
och remove ’#’ för att avkommentera den.
Detta kommer att hämta mod_rewrite.
Hitta sedan alla instanser av AllowOverride None
och ändra dem till AllowOverride All
.
Värdet ”All” innebär att alla direktiv kan åsidosättas.
När du är klar kan du save filen httpd.conf och close den. Därefter klickar du på ”Stop” på Apache-modulen i XAMPP:s kontrollpanel och på ”Start” igen för att starta om den.
Gå sedan tillbaka till din adminpanel för att se om dina permalänkar fungerar.
Vi hoppas att den här artikeln hjälpte dig att lösa posterna som returnerar 404 error i WordPress. Du kanske också vill se vår guide till de vanligaste WordPress-felen och hur du fixar dem, tillsammans med våra expertval för de bästa WordPress-tilläggen för att utveckla din site.
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Nweke Nathaniel says
I unpublished some posts from my site and I have linked some internal links to the posts, pls, how can I redirect the posts url to the homepage instead of showing ”page not found”
WPBeginner Comments says
The simplest solution likely would be to redirect all 404 errors to the homepage. To do this, check out this step-by-step guide: https://www.wpbeginner.com/wp-tutorials/how-to-redirect-your-404-page-to-the-home-page-in-wordpress/
Dayo Olobayo says
I get the 404 error on posts I have deleted and do not wish to redirect them to other articles. How do I solve that?
WPBeginner Support says
In that case you would want to redirect the posts to your homepage as that URL would show a 404 error if there is nothing to show.
Administratör
Dayo Olobayo says
This looks so simple yet very helpful. I’ve never even considered that alternative before. I’ll do that right away. Thanks a million!
Moinuddin Waheed says
This is one of the most occuring error for wordpress websites.
this is really frustrating as it seems to get stuck and leading to nowhere.
I have solved the issue by saving the permalink.
I didn’t know about the other steps.
I really appreciate the efforts to make it holistic by including all the steps to resolve this error.
WPBeginner Support says
Glad we could share the other options
Administratör
mohadese esmaeeli says
Hello. The 404 error can be really frustrating, and we’ve all encountered it at least once. The situation becomes challenging when everything appears to be correct, there are no broken links, yet the 404 error persists. I faced this issue once, and it was resolved by adjusting the permalink settings.
amir says
Hi
in my case, a plugin named as ”WebP Express” create a htaccess file in uploads folder that restrict my access to some images.
try rename or remove it and see if the problem still exist.
WPBeginner Support says
Thank you for sharing this suggestion to check for multiple htaccess files.
Administratör
Eriab Nsereko says
Syed & the team u saved my whole entire day! My homepage was actually loading well.. but the other pages couldn’t load. So, I pasted the code in my .htaccess file and it did absolutely like magic.
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
WPBeginner Support says
Glad we could help!
Administratör
David Helleskov Fønsbo says
Thanks – None of the suggested solutions did work for me. Looks like the typical permalink error but it isn’t.
Saving permalink again does not create a new .htaccess.
WPBeginner Support says
If none of the methods in our guide are working for you, please reach out to your hosting provider and they should be able to help fix the issue.
Administratör
Victor says
The updating permalinks fix worked. Fastest solution ever. Thank you for writing this piece
WPBeginner Support says
You’re welcome, glad our guide was helpful!
Administratör
Julie says
Thank you for the quick fix! Appreciate the help.
WPBeginner Support says
You’re welcome, glad our guide could help you!
Administratör
Frank Thomas says
Thank you for this post. I was missing the .htaccess files after moving sites and of course the wordpress code in them. I’ve replaced it all and voila! We are live at 5. Thanks.
WPBeginner Support says
You’re welcome, glad to hear the guide helped!
Administratör
anand says
i have try to your guideline but not working my website again showing same error 404
WPBeginner Support says
If none of the recommendations from our guide could solve your error, please reach out to your hosting provider and they should be able to take a look and help!
Administratör
Harald says
Hi,
saving permalink helped me too, but it keeps returning over and over again after some days.
I have no clue what causes it.
WPBeginner Support says
If it is a constantly recurring error, we would recommend reaching out to your hosting provider and they can either look at their error logs for the site or keep an eye on your site for the specific error causing the problem.
Administratör
Mete says
Thank you very much.solved my problem
WPBeginner Support says
Glad our guide was helpful!
Administratör
Emmanuel says
This is my lifesaver. My site is working fine after modifying the .htaccess files.
Thanks a ton!
WPBeginner Support says
Glad our guide could help!
Administratör
Jon says
For me the problem was I forced a redirect from mydomain.com to ww.mydomain.com, but in wordpress the site URL said mydomain.com. After changing the redirection to ww.mydomain.com -> mydomain.com everything worked.
WPBeginner Support says
Thanks for sharing this for those who may also have this issue!
Administratör
Mario Nwolisah says
Thank you! It worked. I really appreciate.
WPBeginner Support says
Glad our article was helpful!
Administratör
Jess says
Thank you – this saved me!
WPBeginner Support says
Happy to hear our guide could help!
Administratör
Cristian says
Thank you, it works for me!!!
WPBeginner Support says
Glad our recommendations were able to assist!
Administratör
Samir K Al Busaidy says
I was panicking and thinking that my website was hacked or had malware. As I read your writing and you wrote not to worry, I began to relax. The first option (permalink) worked for me immediately…
Thanks
WPBeginner Support says
Glad our guide was able to help
Administratör
Udaykumar Posia says
This worked. Thank you so much.
WPBeginner Support says
Glad our guide could help
Administratör
Max Legault says
On IIS there is no .htaccess file but the key is still the permalink settings. Just hitting Save didn’t fix it but changing the Custom Structure to Plain worked like a charm. Thanks for the push in the right direction.
WPBeginner Support says
Glad you were able to find the solution for your issue
Administratör
Collin says
I love you for this! This was an easy fix. I was in full panic mode!
WPBeginner Support says
Glad our guide was able to help
Administratör
Zack says
Thank you so much. It worked!
WPBeginner Support says
Glad our guide was helpful
Administratör
Steve Barnard says
Dang! Can’t thank you enough for this – super simple fix worked perfectly – just hit save changes on the permalinks settings page and viola’ – my pages are back. Thank you!!
WPBeginner Support says
Glad our guide could help
Administratör
A.S.M. Arifur Rahman says
Thanks a lot, settings saved method works, Now my post open fine.
kris says
honestly thank you so much! without fail your site always comes thru with answers that work. thank you so much!
(now I just wish I knew what caused it to get out of whack in the first place. oh well.)
Chris says
This article just saved me from a panic attack Lol. The solution worked great. Thanks for making this video.
Muhammad Tahir says
i didn’t solve this issue by using all the methods that you are discussed?
WPBeginner Support says
If none of our methods in this guide worked for you, we would recommend reaching out to the support for your hosting provider to ensure there is not an error on their end.
Administratör
Duane Wiese says
None of the above suggestions worked so I did some further searching. I came across someone who suggested switching off the mod security under the security section in cpanel.
I tried this and it worked. I also tested it by switching it back on after a change and then trying another change and BAM, 404 error.
WPBeginner Support says
Thanks for sharing this should someone else run into this issue. Not every host allows access to that specific file but if you reach out to your host they can normally disable or change it for you
Administratör
Dave Emma says
Disabling ModSecurity fixed mine.
I actually tried permalinks plus rewriting .htaccess, but that didn’t solve my problem. I’m glad I read comments. Many thanks guys for sharing.
Elango says
Thanks, it was so simple and the problem solved. No other pages were visible after I migrated to another server. I added the lines to .htaccess file and uploaded the same. Now all the pages are being displays without the 404 error and I am able to access my WP dashboard too. Thanks a lot.
WPBeginner Support says
Glad our guide was able to help
Administratör
Islombek says
My posts are showing 404 error after installing ssl certificate. How can I fix it? I tried everything mentioned above, but none helped.
WPBeginner Support says
If you are changing your site’s URL to HTTPS you would want to follow our guide below:
https://www.wpbeginner.com/wp-tutorials/how-to-add-ssl-and-https-in-wordpress/
Administratör
Dennis Yildirim says
My .htaccess file is exactly the same with that code but nevertheless I did whatever in the post. did not work, saved permalinks through admin console, did not work. Manually edits, no luck. Deleted the .htaccess and recreated it by saving it from admin console, again did not work. Nothing works. Don’t know how did it even work on others?
WPBeginner Support says
If none of the recommendations from our article were able to help we would recommend reaching out to your hosting provider as that can be a sign that there is an issue on your host’s end.
Administratör
Kuldeep Singh says
You saved my day. I got this issue after transferring my site from one hosting to another. I couldn’t believe it was so simple to fix the issue. Many Thanks WpBeginner team!
WPBeginner Support says
Glad our guide was helpful
Administratör
Rick says
I never reply to these things but just wanted to jump on here and say thank you! I’ve been having this issue a lot and having to wait ages for support to help me and so finally had a hunt around, found this, and can now fix it myself. You legend!! Much appreciated
WPBeginner Support says
Glad our guide was helpful
Administratör
Elroy says
Thanks a lot Wpbeginner it woked just fine.
WPBeginner Support says
Glad our guide was helpful
Administratör
Noble says
Thank you very much, it worked instantaneously!
WPBeginner Support says
Glad our guide could help
Administratör
carol hannah says
Help! It didn’t work and I can’t possibly work out how to do the .htaccessfile thingy?
WPBeginner Support says
You would either need to use FTP which we cover on the page below:
https://www.wpbeginner.com/glossary/ftp/
Or reach out to your hosting provider and they would be able to assist.
Administratör
Christopher Krohn says
Thank you, thank you, thank you!
WPBeginner Support says
Glad our guide was helpful
Administratör
Dan says
Man this fixed my WP site! THANK YOU!
WPBeginner Support says
Glad our guide was helpful
Administratör
Molly says
Thank you for a million time!!!!!
WPBeginner Support says
Glad our guide was helpful
Administratör
Amin Omer says
Thank you very much
WPBeginner Support says
You’re welcome
Administratör
Afan says
One of solutions to correct the issue with the Permalink change is simply delete the .htaccess file – WordPress will recreate it again automatically.
But, before you delete it, copy the file on your computer, just in case…
WPBeginner Support says
If someone has customized their htaccess file then that would be a good idea. Otherwise, WordPress should auto regenerate the default information in the file where most wouldn’t need to worry.
Administratör
James Monroe says
Saving the permalinks settings worked perfectly. Such a simple solution to what looked like a serious problem! Thank you!
WPBeginner Support says
Glad our recommendation was helpful
Administratör
mukhtar says
its works fine 100 %
and easy to solve my problem, we are very very thankful to you about it
WPBeginner Support says
Glad our guide was helpful
Administratör
Sarah says
Wow!! I’ve spent all evening trying to fix this and that’s how easy it was! THANK YOU!!
WPBeginner Support says
Glad our guide was helpful
Administratör
Rimzan farook says
Thanks fixed it as you described changed my post date to post name, thanks a ton
WPBeginner Support says
Glad our recommendations could help
Administratör
Muhammad Zeeshan says
I’m facing 404 error while adding new plugin , theme , editing any post or product, editing any page ..
I’ve try to save permalinks and also tried to change .htaccess .. But not this given solution is working for me.
WPBeginner Support says
You would want to reach out to your hosting provider to see if you are running into any errors on their server’s end.
Administratör
Ayobami says
I’m having error 404 issues on my website, I can’t access to the website at all what can I do?
WPBeginner Support says
You would use the htaccess method from this guide or reach out to your hosting provider to be able to assist you
Administratör
samith says
I can’t login my WP dashboard seen ”nginx 404 not found error”
WPBeginner Support says
For that specific error, you would want to reach out to your hosting provider to take a look.
Administratör
Sammy says
A BIG Thank You… It solved the headache!
WPBeginner Support says
Glad our guide was helpful
Administratör