Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Cup
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

Hur man fixar WordPress Posts som returnerar 404 Error (Step-by-Step)

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.

How to fix WordPress posts returning 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

Subscribe to WPBeginner

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.

Activating a default WordPress theme

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.

WPCode error warning

Om ingen av dessa lösningar fungerar, gå vidare till nästa metod där vi troubleshootar 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”.

Check Permalinks

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”.

.htaccess 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”.

Change file attributes for the .htaccess file to 666

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.

Edit .htaccess file

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)”.

The Apache (httpd.conf) menu on XAMPP

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.

Finding the rewrite_module on httpd.conf file

Hitta sedan alla instanser av AllowOverride None och ändra dem till AllowOverride All.

Värdet ”All” innebär att alla direktiv kan åsidosättas.

Changing AllowOverride None to AllowOverride All

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.

Avslöjande: Vårt innehåll stöds av våra läsare. Det innebär att om du klickar på några av våra länkar, kan vi tjäna en provision. Se hur WPBeginner finansieras, varför det är viktigt, och hur du kan stödja oss. Här är vår editoriala process.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Den ultimata WordPress-verktygslådan

Få GRATIS tillgång till vår verktygslåda - en samling WordPress-relaterade produkter och resurser som varje professionell användare bör ha!

Reader Interactions

773 kommentarerLämna ett svar

  1. Syed Balkhi

    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!

  2. Farid

    Thank you very much for precious article that is useful to fixed my website problem.. i always prefer your web solution regarding in problem in wordpress cms.

    Thank you..;.

    • WPBeginner Support

      You’re welcome, glad our guides have been helpful :)

      Administratör

  3. Ben

    Just wanted to leave a thank you comment! Your guides on WordPress are second to none! I have learnt so much reading your blog and every time I Google a problem..I am looking for your website and that is where I will click! Great and simple instructions even on the most complicated WordPress issues…you are awesome! Thanks.

    • WPBeginner Support

      You’re welcome, glad you like our content and hope our guides continue to be helpful :)

      Administratör

  4. David Naugle

    This totally worked! I just updated my PHP and dashboard and home pages was accessible but not any of my post pages.
    Thx

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  5. Vivian S.

    Thank You so much it saved my life! I had to move my WordPress website to a new server and it took me a whole day to fix everything. I wish WP had an easy way to do this. :)

  6. Gustavo

    Thank you guys, you’re AWESOME, ALLWAYS!

    • WPBeginner Support

      You’re welcome :)

      Administratör

  7. Don Current

    I tried everything in the article with no success. What I ended up doing was choosing a different Permalink structure and saving it, and then going back to the structure I wanted and saving it. Then all was well.

    • WPBeginner Support

      Thanks for sharing the method that worked for you :)

      Administratör

  8. James

    I accidentally deleted .htaccess file when doing 301 and got the 404 not found error. Your tutorial came to my rescue. Just by saving the permalinks and it worked. Thank you.

    • WPBeginner Support

      You’re welcome, glad our guide could help :)

      Administratör

  9. Ivan

    Saved me! I am dealing with forces I cannot comprehend, and this explanation and tip was really helpful!

    • WPBeginner Support

      Glad our guide was helpful :)

      Administratör

  10. Uwemedimo Usa

    Wow, I’m shocked at how fast this worked. I recently migrated my site from a subdomain to the root domain and none of my links were working. All I did was go to permalinks in settings and click ”save changes.” That was all. Wow. And I was really scared I’d broken something. Thank you.

    • WPBeginner Support

      You’re welcome, glad we were able to help :)

      Administratör

  11. DNNY

    What do you do if you cant even get into your WP
    dashboard

  12. Katie

    Hi, thanks for the tips. I still can’t seem to fix the error. Have reset Permalinks, installed a redirect plugin (doesn’t help if wanting to redirect to the homepage). I can’t work out how to alter the .htaccess and not really confident to do it. Any other suggestions?

  13. Fola

    Thanks You saved me a lot of hassles

    • WPBeginner Support

      You’re welcome :)

      Administratör

  14. Jill

    THANK YOU for this post! I had a primary domain that I let go and needed to move two sites on my hosting plan…. 1 to the primary domain position and 1 to an addon domain position which was formerly a subdomain position. I broke a lot of stuff. With some logical thought, I got most of it all back… EXCEPT all the pages on the primary domain site couldn’t be viewed on the live site once you clicked on them or the menu links. The home page loaded beautifully, but when you clicked a post or link… the errors popped up. This trick resolved those issues… so THANK YOU again! You saved the day!

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  15. umesh

    I just change the permalink directly and it shows 404 error I couldn’t access my website it redirects me to another site which is not mine

    • WPBeginner Support

      You would want to reach out to your hosting provider to ensure your domain is set up properly and there isn’t any malicious code on your site.

      Administratör

  16. faheem

    404 Not Found
    nginx/1.10.3 (Ubuntu)
    please give me solution for that

    • WPBeginner Support

      For nginx, at the moment you would want to reach out to your hosting provider and they should be able to assist.

      Administratör

  17. Carene

    I’m busy building a website via wordpress & cpanel. I by accident deleted the url in my dashboard. Now I don’t get even access. Is their any way to fix it.

  18. Long Nguyen-Vu

    Just want to let you know that you’ve helped me save a lot of time searching.
    Thanks so much.

    • WPBeginner Support

      You’re welcome, glad our guide was able to help :)

      Administratör

  19. Jim

    OMG I LOVE YOU
    updating the permalinks and all is gold
    THANK YOU

    • WPBeginner Support

      Glad our guide was able to help :)

      Administratör

  20. Brandon G.

    Updating permalinks fixed my 404 errors. Thanks!

    • WPBeginner Support

      You’re welcome :)

      Administratör

  21. Musthafa

    Updating the permalink worked perfectly. Thanks guys!

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  22. ami

    thanks its is working

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  23. Heather

    Simply saving changes in my permalinks did the trick. Thank you!

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  24. Ekemini Robert

    After saving changed for the permalink, it still returned the 404 error. Then I used the clear cache WP button at the top and the problem was solved.

    • WPBeginner Support

      Glad you were able to resolve the issue :)

      Administratör

  25. Didar

    Thank you so much !

    • WPBeginner Support

      You’re welcome :)

      Administratör

  26. Ashish Agarwal

    Thanks so much for this post. You are a lifesaver. Clicking ’Save Changes’ on Permalinks under Settings did the job for me.

    • WPBeginner Support

      Glad our recommendation was able to help :)

      Administratör

  27. Alex

    I have issues on 404 Page not found.
    I tried updating the permalinks but still not working and I also checked the .htacess file in our server and it’s the same on the above sample. But still not working.

    • WPBeginner Support

      You may want to reach out to your hosting provider to ensure there are no issues on their end that could be a part of the issue

      Administratör

  28. Luiz Felipe

    This simple solution saved me! thanks!!!!!!!

    • WPBeginner Support

      You’re welcome :)

      Administratör

  29. Steve Dzwonczyk

    The 2nd method worked for me (FTP and edit of the .htaccess file). Thank you very much.

    • WPBeginner Support

      You’re welcome, glad our recommendation was helpful :)

      Administratör

  30. Pranesh

    Thank you very much

    • WPBeginner Support

      You’re welcome :)

      Administratör

  31. Anas

    Thank you so much for this helpful tip. Was really bugging me a lot

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  32. Michelle Kwok

    thanks a lot.. it’s weird.. works at step one =)

    • WPBeginner Support

      You’re welcome, glad our recommendation was able to help :)

      Administratör

  33. Steph

    This worked at step 1. Thank you!

    • WPBeginner Support

      You’re welcome, glad our guide could be helpful :)

      Administratör

  34. Ishmael

    Many thanks, solved my problem.

    • WPBeginner Support

      You’re welcome, glad our guide was helpful :)

      Administratör

  35. Shiraz

    This article helped me bring my website back on. Thank you.

    • WPBeginner Support

      You’re welcome :)

      Administratör

  36. mariam

    Thanks for this post,it really solved my 404 error problems

    • WPBeginner Support

      Glad our recommendations were able to help :)

      Administratör

  37. Tim

    Just a quick note to say thank you so much! I had just activated a CDN (learning as I go) and thought I had broken my site and went searching everywhere but here was the answer…phew!

    • WPBeginner Support

      Glad our guide could help :)

      Administratör

  38. Lou Sarmiento

    Hi!

    I’ve added the htaccess script, updated my wordpress but still I need to resave the permalinks. Any other solution?

    Thanks!

  39. Ayesha

    i have 404 error but cannot acces neither the site or the wordpress. how can you access wordpress admin to solve the problem??

  40. Nera

    Lifesaver! It worked! Flushing permalinks! Haleluja… THANKS!

    • WPBeginner Support

      Glad our recommendation could help :)

      Administratör

  41. wajid virk

    on clicking save changes my problem Resolved, WP beginner is a part of my journey to learn WordPress more and more.

    • WPBeginner Support

      Glad we can be here to help :)

      Administratör

  42. Safa

    You just saved me, Thanks :D

    • WPBeginner Support

      You’re welcome :)

      Administratör

  43. Nora

    Thank you so much! This saved our corporate website :D

    • WPBeginner Support

      Glad our article was helpful :)

      Administratör

  44. Mary Ann

    Will it work in 404 error of WordPress Multisite once I visit the admin dashboard of the sub-sites?

    • WPBeginner Support

      It would depend on the source of the error but this can certainly be one solution.

      Administratör

  45. beginner

    Thank you, it solved the issue straight away!

    • WPBeginner Support

      Glad our article could help :)

      Administratör

  46. Civali

    .htaccess example worked for me, tks!

    • WPBeginner Support

      Glad our recommendation could help :)

      Administratör

  47. Vishwajeet

    So I checked all solutions and comments. I have same issue with a twist. I can see the pages when I am changing it to use the Page ID but not when I am selecting the Post-Name? Any solution to this? I know its weird.

    • WPBeginner Support

      You may want to delete the current htaccess file and if that does not fix the issue, reach out to your host to ensure there isn’t an underlying error causing the problem.

      Administratör

  48. Mireille

    Hello,
    I just wanted to let you know that your website is of such great help ! I built my first WordPress website and I managed to resolve many issues thanks to your articles. Thank you !

    • WPBeginner Support

      Thank you, glad our articles have been helpful :)

      Administratör

  49. Benson Kanyi

    Hello Guys,

    I have been facing this issue for the last three days after migrating a new site from my localhost to an online CPanel server. Having tried a million and one option from various forums, none of them could work at all. The only solution that seems to work is disabling Mod_Security in the CPanel. I just did it and it works like a champ. Thanks

    • WPBeginner Support

      Thanks for sharing the solution that worked for you :)

      Administratör

    • hüseyin

      I worked for days. It happened. cpanel mod security disable. solved the problem. Thanks BENSON

  50. Christopher

    Worked! Thanks!

    • WPBeginner Support

      Glad our recommendation worked for you :)

      Administratör

  51. Peter

    you blog saved me from disaster thanks so much. im learning so much now

    • WPBeginner Support

      Glad our recommendation could help :)

      Administratör

Lämna ett svar

Tack för att du väljer att lämna en kommentar. Tänk på att alla kommentarer modereras enligt våra policy för kommentarer, och din e-postadress kommer INTE att publiceras. Vänligen använd INTE nyckelord i namnfältet. Låt oss ha en personlig och meningsfull konversation.