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

    Well, your tip saved me hours of searching – many thanks

  3. Nima Arefi

    Thank’s you saved my life :d

  4. Juan

    Hello, I have a problem since I migrate the website from localhost to a server, the main page looks good but the menu is not displayed but the links do not work always throws error 404.
    They can help me, this is a cause of a migration from a local server.

  5. Marissa

    I can’t thank you enough for such a simple tutorial!! Everything else I found made it seem so difficult. I recently switched from http to https and it has been one problem after another..

    • WPBeginner Support

      Hi Marissa,

      Glad you found this tutorial helpful. Don’t forget to join us on Twitter for more WordPress tips and tutorials.

      Administratör

  6. Rick

    I didn’t have an .htaccess file so I created one with the info you provided above; then uploaded it and the site works perfectly again. Thanks!

  7. Curtis

    Hi I have done all the above and noticed the bit of text to copy and paste was already in there! It still is not working and im stressing out!

    • Tibi

      I’ve done the same thing and nothing changed, the home page still not found :(

      Please contact me if you find a solution

  8. Patrick

    Wow. This really saved my bacon. Thank you so much for the tip on simply saving the permalinks page. Incredible advice! :)

  9. Alexis

    hello! i’ve reset permalinks many times to deal with the 404 error. this time when i hit save a file downloaded to my computer: options-permalink.php and the site broke. just got a white screen and each time a file downloaded. finally i got the default permalinks to work but this is not a great solution. does this sound familiar to you? tech support didn’t think it was the .htaccess file but i’m not convinces. moved site from one host to another. any help would be much appreciated.

  10. Mike Birdsall

    How do I update settings if I can’t log into the WP admin. I get the 404 error when going to /wp-admin

  11. Kelly

    So helpful!! thank you!!!!!!

  12. seun

    Hello, please help, i seem not getting solution through this tutorial cos i can’
    t access my dashboard, i keep getting this message any site directory i open.

    Not Found

    The requested URL /index.php was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

  13. Clint

    Thank you, just clicking save on my permalink page (which has been customised for years) worked immediately.

    • Chris Keeble

      Perfect!

      Clicking Save Changes on Settings > Permalinks works first time.

  14. tamim

    Wow! that’s a great solution.

  15. Jason

    Hi, I was having the 404 error problem. Homepage works fine, all other links have the 404 error. Tried the method you suggested in wordpress settings permalinks and click save changes but it didn’t work for me.

    Saw some post earlier about sync the htaccess file through the webhosting settings page somewhere but don’t really know how to do it. Any advice? Thanks

  16. Mohamad Zidani

    Hi

    I was using Fv Top Level Cats, when i removed still redirection worked from

    example.com/category/tech to

    example.com/tech.

    i try your solution and it doesn’t work.

  17. Joerg Naussed

    the 404 appear right away what happen?

  18. Tamara

    That worked!! Thank you

  19. Lijo Jose

    Thank you, My problem was solved

  20. Mariana Cervantes

    Thank you so much!!!! My problem was fixed with the permalink solution :)

  21. Michael

    If this error is affecting your login page, go to .htaccess and remove:

    ”deny from all”
    ”allow from 00.00.00.00”

  22. Matt Kay

    Fantastic – I had moved my site from one server to another and started getting worried about 404 errors. The fix worked perfectly – so easy!

  23. Bienvenido

    A very simple answer to a hair pulling issue. Thanks a bunch. BTW this issue started after I installed BJ Lazy Loading.

  24. Gail Gardner

    Thank you! This did the trick.

  25. Ahmed

    Hi, One of my site was hacked. There was few hundreds article inserted. Now those has been removed. Google webmaster console showing those as 404.

    How this can affect my site how to fix this?
    Thanks

  26. Stephanie

    Wow, thank you! This worked perfectly.

  27. Mawuli Tanor

    Spot on! On the dot!
    First fix worked.

    Thanks a lot!

  28. Peter Mazzi

    Thanks. pity there’s no rating on this page. *****

  29. David M. Curtis

    Thank you for posting this article. I had spent months building a store / blog and today none of my pages or posts were working other than the front home page, all other links were taking me to a 404 error page. I was about to start completely over – re-peat months of work. This article saved my site. Now everything is working again. I can’t thank you enough.

    • WPBeginner Support

      Hi David,

      We are glad you found the article helpful :) Don’t forget to join us on Twitter for more WordPress tips and tutorials.

      Administratör

    • Robin

      Hi there, completely stuck here, not a computer guy at all so it’s all greek to me. my homepage is good but I’ve created another 5 pages such as blog post, services, etc. and every time I try to view the page I’ve just created I get NOT FOUND The requested URL /services/ was not found on this server.” I’ve tried saving changes didn’t make any difference and I have no idea what an FTP is. Any help ? thx

      • WPBeginner Support

        Hey Robin,

        Try updating your permalink structure. Simply visit Settings » Permalinks and then click on the save changes button without changing anything.

        Administratör

  30. Preet Karan

    Hi everyone,

    i installed yoastseo plugin. i generated the XML site successfully, but when i tested it on google search console it is showing 404 error.

    i tried the method listed in article but the problem still persist.
    also i need to mention that in the CCpanel there are two files of the same name htaaccess and htaaccess.1 (with the same code written that has been mentioned by article above ); is it normal,
    can you help me wth the issue

  31. David

    I can’t believe just clicking ”Save Changes” worked. Thanks!

  32. jorge

    hello there im I would really appreciate help I followed the instructions on saving changes on permalinks not a computer person so do not know how to do the other after is showing me this

    Fatal error: Class ’Epsilon_Editor_Custom_Control’ not found

  33. yugal joshi

    great man..thank you much.. i open my site but its throwing 502 error then 503 error and then lastly 500 error..then i solve the problem of 500 from cpanel threw ur post.
    but when i open my post pages its showed 404 error then i googled it and find ur post…thanks…

  34. Bren

    In the event this is a new server, or an Apache upgrade you may have to check the following:

    Open the httpd.conf ie: /etc/httpd/conf/httpd.conf.
    Change the AllowOverride None to AllowOverride All.
    Save changes
    Restart the Apache server.

  35. Mariyam

    Wow, as easy as that, Thank you!

  36. Ashley Adams

    Having a little trouble… After I hit save changes on the permalink page, another 404 error popped up.

  37. Katherine

    This just saved me hundreds of dollars in help. <3

  38. James V

    Quick fix…thanks for the help!

  39. marco

    still having problems, not sure what to do, i followed steps above, and get same results. my web host company uses windows 2012 server so no .htaccess file. so many of these help posts refer to .htaccess which windows does not use. they use the web.config file i think, is that correct? please help

  40. marco

    I have followed the above steps, but still does not work. I am on windows 2012 R12 server and do not have a .htaccess file, even while in FTP force hidden files to display . are there instructions on how to fix this problem when on windows server

    • WPBeginner Support

      Hey Marco,

      First you need to download a backup of your existing web.config file to your computer. After that you need to edit the file on your server and add following rule to the system.webServer element:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration>
      <system.webServer>
      <rewrite>
      <rules>
      <rule name="WordPress Rule" stopProcessing="true">
      <match url=".*" />
      <conditions>
      <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
      <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
      </conditions>
      <action type="Rewrite" url="index.php" />
      </rule>
      </rules>
      </rewrite>
      </system.webServer>
      </configuration>
      

      Administratör

      • Salami

        Hi WPBeginner Support. I have tried all the solutions pasted on this blog to solve the same problem(404 error on wordpress) am confronting now since two days, but i haven’t got it right. Am developing my website with windows platform using wordpress. Please what other thing I should do to solve this problem?
        Thanks in anticipation to your response.

  41. Dale

    Amazing help thank you! As simple as clicking save!

  42. david c

    worked like a charm – thank you thank you!

  43. Tom

    Many thanks,

    Worked a treat!

  44. Michelle

    I want to hug you for all your extremely helpful posts. Thank you very much!!!

  45. Steve Andrews

    I migrated a site to, imported the mySQL DB and uploaded the entire file structure of the wordpress directory.

    I still got a 404 error for everything but the home page, and re-saving the config in the permalinks section did not work.

    What worked for me was renaming the htaccess file on the FTP site to htaccessOLD so it would not be referenced, but I still have it backed up if needed, then I went and saved the permalink options, had to chose what type of link I wanted (IE date, page no or description). Once I saved all the pages were back up and running.

    Thanks for the post, it gave me the pointers to find this and fix it.

  46. Rene

    I followed the exact steps but unfortunately they don’t work for me. I keep getting errors 404 despite saving my permalink info, removing .htaccess and re-generating it. I am able to view my home page, but as soon as I want to visit a sub page, the error 404 pops up. I also tried switching to WPs default themes, also that doesn’t help. Are there any advices for ”advanced” bug solving in case of 404 errors?

    • WPBeginner Support

      Hey Rene,

      Try updating WordPress URLs by visiting the Settings > General page. Make sure that your site and WordPress URL are the same.

      Administratör

  47. sampurna

    Hey. I have a little problem with 404. I had changed the permalink of a single post. now for a certain keyword google is displaying the same post in two different positions with same title but different url and one has 404 error. please help.

      • Rene

        Not needed, problem is fixed. I coincidentally found out that my host is reading a different .htaccess file than the one that WP generates. So a ”sync” had to be done via their webhosting portal, that was all. Now it works, thanks a lot anyway and perhaps this alternative solution is still useful for other to know that may have a similar setup by their host. Rgds!

        • Carey

          Same here! Needed to ’sync’ the htaccess file through the webhosting settings page somewhere… thanks for the tip!

  48. Rajinder S. Gill

    This was quick. Thank you :-)

  49. Lois

    You saved my life today. I was at the verge of crying because after creating a post, I was unable to read the post. it returned 404 error. I eearched several websites for answers but your post was well explicit and once I changed the permalink structure, it worked. Thank you thank you.

  50. Kaylee

    I’m still now following at where you exactly change the permissions at. Could you please explain?

    • Mike lavie

      The solution: Login to your server using FTP, and modify the folders like /wp-content/ and /wp-includes/ are located. The easiest thing you can do is to temporarily make the file writeable by changing the permissions to 777. Then repeat the original solution.
      Go to Settings » Permalinks, and simply click on Save Changes button.
      Don’t forget to change the permissions back to 755 ( /wp-content/ and /wp-includes/ ).
      I do it for is perfect now!

  51. Lukas

    Great, that help a lot!

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.