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

    thanks man u saved my life

  3. Phannipha

    Thank you for very useful sharing. Just only one click can solve the problem:)

  4. Ehiz Mikey

    A million thanks Syed. I was stuck here for a couple of weeks. A fix indeed.

  5. Kaycee

    Hi. Really nice article.

    I had a 500 internal server error issue with my site when I tried using the W3 Total Cache plugin.

    To fix this, I renamed the .htaccess file to .htaccessbak. After doing this, I noticed that the 500 error cleared but then I got a 404 error! All the links and pages on my site returned a 404.

    On the All Pages section, I see a link that says ”Purge from cache”

    Please what do I do to clear this issue?

  6. Stanley

    You’re a life saver, worked for me.

    Really grateful,

    Thank you

  7. syed

    thanks it works for me….

    • Christian Fraunholz

      but why is that happening and how to fix it forever?

  8. Karma

    I tried to follow your direction in fixing my problem, it took for about a day, but I didn’t find the good result.

    Then I gave up and contacted my hosting. And it fixed only in 5 minutes. Lol the problem came from the hosting…

  9. Mark Kay

    By careful with post variables names. I had a contact form with an input field called ”name”, that caused WordPress to show the 404 page. Took me a long time to figure out the problem. I fixed it be changing the field name from ”name” to ”your-name”.

  10. Ivan

    thanks you saved my life.

  11. Ramzan

    My problem is that I m going to wp adminin
    And want to edit post it is not going in edit mode of post and page gives me error page not found 404 but my site and its pages are opening well in browser
    Plz guide me I can solve this problem

    • Ben

      Samo rpoblem here. Cannot edit the existing posts or add new one. I get 404 for both

  12. Sunit

    Hi, I have tried following the above steps but my issue is this: when I visit my website directly by putting typing the url, then it works fine. But, when i type in my site url in google search box and then click on the link from the search results, I get the 404 error or message saying ”your connection is not private”.
    My website is http://www.example.com but google search result shows it as https://example.com/

    So not sure what the issue is. I used to have wordpress.com but now I am dong self-host using HG.

    Any help will be appreciated.
    Thanks

    • WPBeginner Support

      www is considered a subdomain of a domain. So basically a site with www and without www will be considered two different sites by search engines. Go to Settings > General page to change your site URL from http://www.example.com to just example.com.

      WordPress.com enabled https for all custom domains on WordPress.com. This means Google had already crawled your website with https in the URL. You can install free https using Let’s Encrypt.

      Administratör

  13. Paul Nicholson

    Great worked for me thanks!!

  14. Shashdhar S

    Thanks a lot , the second option worked for me ….. Thank you so muich :-)

  15. eliana

    Just THANK YOU!

    eli

  16. Michaela

    hi, I tried first solution, nothing happened. I wanted to try the second, but I cannot find the .htaccess file. Not in FTP, not even in my WP online editor. I had this issue today for the first time. I use WPML plugin, until now everything went without problem, but today my translated post in English throws this 404 Error. Any idea what shall I do if I cannot locate the .htaccess file?
    Thanks!

    • Michaela

      I noticed one thing. The post in the editor shows me the following link:

      example.com/2016/09/15/where-eat-in-barcelona/?lang=en

      but when I click to see the post, or from any RSS feed click on the published post, the link showing 404 error is as follows:
      example.com/?p=11409&lang=en

  17. Shirish Dhungel

    Well thanks! I remember, that WP Super Cache official stated to remove rewrite code from .htaccess. After that, my posts redirected to 404. Thanks to you, now my site is perfectly fine.

  18. Muhammad Nasir

    Thanks it worked for me, thank you so much.

  19. Akhelesh

    Do I have to remove the code snippet I added to htacces file after my problem has been solved?

  20. Jessica

    Can someone contact me please? I am so new to these I don’t even know what a FTP server is…

  21. Rohan khamkar

    Sir, when I post a new post it gives me error that 404 page not found. Previously everything was fine but when I add a new user and give him a role of administrator from that time I can’t post new post. Any solution Please. Thank you in advance.

    • WPBeginner Support

      You should never give administrator role to a user you don’t trust. You can always change back their role by going to Users page and then clicking on the Edit link below the user that you want to change. After that you check your site’s permalink structure. See if they installed any new plugin and if they did, then deactivate that plugin.

      Administratör

  22. Shivani Sehdev

    Wow……….. Solved a long ago problem .
    Thanks A lot.

  23. R Donahoo

    Didn’t work on my apache server. Had an additional step to allow mod_rewrite to actually work. Edit your httpd.conf file and add ’Allowoverride all’. For example:

    DocumentRoot /var/www

    find the section that sets up the directory options, such as:

    Options Indexes FollowSymLinks MultiViews
    Order allow,deny
    allow from all

    add Allowoverride all

    Options Indexes FollowSymLinks MultiViews
    AllowOverride all
    Order allow,deny
    allow from all

    save and restart the web server to re-read the updated configuration.

    All was well after that.

    Thanks for your useful post moving me into the right direction.

    • Arnaud

      forgot about htis #yaDaMan

    • Ben

      Didn’t work for me either :(

      Where can I find this file you are talking about

  24. aderele olutayo samuel

    this worked. …. Thanks

  25. Eva

    I found the some problem. However, I could not log in to the admin page. Could you give solution to mitigate this problem?

  26. Rodrick Green

    This was very easy and very helpful. THANKS A LOT!!!

  27. B Pandey

    thanks for your usefull tip. It worked for me on my website. Thanks a lot

  28. sheldon

    Thank you .
    It worked for me

  29. Rachit Sharma

    but not working for me when i updated permalink with post name and change .htcces file but not worked. any other solution for that.

  30. Ahsan

    Wowww Thank you so much, that was really helpful.
    In my case it was WAMP server, after turning on ”rewrite module” in apache, my problem was solved.
    Thanks.

  31. Kailash

    Wow – this still works. Done a search on google and found articles in wordpress but this was by far the simple-est and bang it works.

    Thanks a mill – saved me a heap of time

  32. Shawn Ritch

    Hello and thanks for all the useful tips. Unfortunately, this tip didn’t work for me. I re-saved my permalinks in WordPress settings (didn’t work) so then I tried your next method and it didn’t work either. I’m thinking the reason for this is because I have different permissions. My original permission is 644. When I change permission to 660 none of my pages work so I believe the 666 permission is wrong as well. I’m using a Go Daddy server if that helps any :/

    I’m at a loss and have no idea what to do from here. However, I can’t afford to have pages that don’t work. Any suggestions would be greatly appreciated.

    Thanks
    Shawn Ritch

  33. Kevin Garcia

    I tried this and it didn’t help me!!! My whole website crashed and had to restore it!!

  34. Hannah Brown

    Thanks, yours was the only place that told me HOW to fix my broken links! You’re the best

  35. Kunal Yande

    Thanks !!
    You save my so much time….

  36. Chris

    How do I fix the issue when I upload a new plugin and then my categories, not posts, become 404?

  37. Bob

    This is great advice. I thought I was going to have to take a deep dive, but two clicks and I’m GTG. Thanks!

  38. Ronn Reason

    hi
    i keep getting this message with my email account;

    Error Oops… a server error occurred and your email was not saved. (#404)

    Please advise ASAP

  39. Gabo

    O.O

    I can’t belive this …. it works, thanks !!!!!

  40. Steve

    I had this problem after moving sites to a new server. Default Permalinks worked, but not the settings I was using.

    I needed the apache server to ”Allow Override” for the htaccess file to take effect.

  41. Vivek

    Hi,

    I need a little help regarding 404 error.

    I am getting 404 error in my Page 2 section.

    I have googled a couple of times. but did not get the solution.

    Could you please tell me what is the reason for it?

  42. Rudy

    My site links will work ONLY after I’ve VIEWED the permalink settings, without any changes, and Voila! The links work again. What is causing this and how can I program this instead of having to log in?

    I’ve tried the following commands in WP-CLI to no avail:

    wp rewrite flush –hard –path=c:\xampp\htdocs\mywordpress

    wp cache flush –path=c:\xampp\htdocs\mywordpress

  43. Amit Schandillia

    This saved my life!!!!!

  44. Patrick

    Thanks man, just pressing the ”Save changes” on the permalink-settings page did it for me! Cheers!

  45. Amanda

    Hi there,

    About an hour ago I was able to remedy a pesky ’500 Internal Service Error’ by following your sage advice and renaming the .htaccess file to .htaccess_old. I was immediately able to access my wp-admin area–and I thought–get going again.

    Unfortunately, something happened which rendered all of my other pages unfindable; each kicking a 404 error.

    I attempted the steps you provided above, but to no avail. Might you have any further suggestions?

    Thank you.

  46. Jessa

    You guys are awesome, this was easy and fast. You guys save me a trouble!

  47. mehdi

    why i coudl not see my post?
    after I send a post my preveous posts appear.
    it made me crazy please remove previous post

    I found a solution to my problem and will say in next post

  48. mehdi

    Hello agin
    thank you for this useful article/ I found a bug in wordpress in rtl language in displaying permalink
    I read your article and encourage to solve the problem with your contribute.
    ——————————————
    my problem in detail:
    1-I created a mysql database(in utf8 general ci)
    2-I installed last wordpress versin(locally) and install my theme(multiup v 1.2 from themeforst)
    3-Next I did import demo as whele.
    in the theme admin panel exixst category portfolio (in this section we create our category with name and slug) then in all post under portfolio section we can create our posts and determine category of post from portfolio category) finally in homepage we have a section that shows portfolio post in category(with their picture)
    In english slug and name the category of portfolio show well but when i change category in portfolio category( slug) into rtl language the category in homepage canvert into charachter like base 64(I think that my slug convert into ansi ie each character convert into 6 charachter)
    How I can overcome my problem?I think I must avoid change slug or show slug into utf8 or unicode . I am beginer in wpordpress , If I khnew wordpress more I could solve this simple problem .Any one with khnowledge of handling hoock and filter and plugin and wordpress can solve this permalink problem . I sure I will solve this problem with your help.
    ———————————-
    I tried the second way you offer (that phpmyadmin in utf8generalci) but it doee not work for me.
    before thansk a lot for helping me.I followed your posts regularly .
    ……………………………….
    1- first I did the trick in above article (this is so good but didnot solve my problem)
    2-

  49. mehdi

    hello
    thanks to contribute you knowledge to others .my english is not well.excuse me.
    I download a wordpress theme with portfolio link in admin panel that in porftoli section we can define some category with name and slug . in post we can determine category from portfolio.
    in homepage we can display post in portfolio category! all thing is ok but wen i chang name and slug into rtl language the title of a group in home page shows like this %d8%a8%d8%b1%d9%86%d8%af%d8%b3%d8%a7%d8%b2%db%8c
    i did your solution in this topic and that another topic(How To Enable Custom Permalinks) but not woks for my problem!

    • WPBeginner Support

      This could happen if your WordPress database is not using UTF-8 character encoding. Please make sure that your database is using utf8_general_ci as collation. You can check that using phpMyAdmin from cpanel. Before you make any changes to your database, please create a complete WordPress backup first.

      Administratör

  50. Atula Gupta

    Thank you so much for fixing my problem in seconds! I was panicking about all my posts giving this error and this solution was so simple! Thanks again.

  51. Sammy

    Thank you, thank you! This was making me crazy and you just helped me fix it in 2 seconds. High five.

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.