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

    It helps.. just on permalink, already fix my error..
    Thanks for this article..

  3. Julius

    Mine is a little different. All the pages are working fine but I get ”page not found” when working in some places in the dashboard. Let’s say for example I’m creating a new page from the dashboard. When I click on publish I get a 404 error.
    And I’ve tried everything above but it’s not working.

  4. Iron65

    Thanks for the tip!! the permalink really saved me!!! In case if any other suffered this by updating Yoast SEO or by just deleting cache, try that one, it will fix it

  5. Monica

    I have been trying to fix this permalink issue in my site for months and now I did it with your instructions. I don’t know why I did everything you said already and after writing the 644 permissions to fix the httaccess file, it went back to non-writeable. Now I did it and fixed the permissions and wrote your code and it worked. i really don’t know which was the difference but this time it did. Maybe that I already fixed the httaccess in the original folder where I have a subfolder with my blog. That is the only thing I did differently. Thanks a lot

  6. Rais Dar

    I am getting a 404(page not found) on my site. What should i do as i tried your methods but still error persists

  7. Chetan

    I had faced the same kind of problem. I used to get 404 Page Not Found error for a page. But the reason was that I and used a permalink slug that was associated with some default page in WordPress. e.g. http://example.com/posts – This is WRONG. Because I cannot use ’posts’ as permalink slug. It is already reserved for some WordPress page. When I changed it to ’my-posts’, so that now my permalink read: http://example.com/my-posts, the error was gone!

  8. md

    hi ,
    i had same htaccess .,however , i delete it and import new one but still same .

  9. dumb

    hay guys ….
    when i change the permalink to anything other than default, my pages wont work i get this error message
    ”The requested URL /wordpress/home/ was not found on this server.

    Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80”

    pl help me out

  10. Ian Scofield

    I just had this with one of my websites. All of my posts worked fine except for one though. Something was bad about the URL. I had to change the post URL.

  11. neelesh

    thanks a lot… ur website has helped me a lot of times and u guys are doing great job. i cant resist myself from thanking you…..

  12. Hardik

    Hi Wpbeginner,
    Actually I just have migrated from hostinger to one of paid hosting. After migration all things are going good. But when I have tried to edit one my post it regularly shows the following error.
    ”Page not found error” ’Apologies, but the page you requested could not be found. Perhaps searching will help.
    When I have landed here I have tried all the solutions which you have share.
    But nothing is working for me.
    Please Help.
    Thanks in advance
    Hardik

  13. Adrienne

    Question? I have an url site, but the data is all new. so there are about 100 old posts that are not longer valid but linked to other sites.. How do I change it to forward to main website, so that Google Search Console can update they crawl records.

    I’m looking, but I don’t see anything for posts that have been deleted and getting a 404 error.

    Thanks,

  14. David

    Thanks was having exactly that issue and this fixed it perfectly!

  15. Mark

    Thank you! So nice to find such an easy fix for such a frustrating mysterious problem.

  16. Xavier

    Woohoo! Thanks for this. I thought my site content had gone to the birds. Doing the permalink ”Save Changes” worked instantly for me.

  17. Pablo

    What if it doesn’t work no matter what you do?

    HELP!

    • Fida

      Hi Pablo Which server do you use? Shared server or VPS?

  18. Steve Jackson

    Thank you for this tip, it was a lifesaver and worked perfectly!

  19. John

    Thank you !!!!

  20. abhishek

    thank you very much it saved my links pretty well

  21. Hugo Nascimento

    Hello guys,

    I have the same issue with a client blog. i’m trying to build a custom form inside post page and when I enable the custom permalinks, the form cannot be accessed.

    When I change permalinks to default, it works out! :/

    Really strange. :/

    • Sarah

      Changing permalinks to default solved my problem too! Thank you!

  22. mojamalenkost

    Thank you so much!!!

  23. victor

    I have this problem .I can’t login to my WordPress dashboard, each time I try to it keeps giving me Error 404 not found. please help me fix this.

  24. Dont Ask Real Name

    Your tip was a life saver. All our posts were just not visible. Your tip helped a lot.

    What i did:

    Updated .htaccess set CHMOD to 666 instead of 660

    Clicked – > Settings -> Permalinks

    Clicked on Defaults and clicked Save Changes

    Again,

    Clicked on Post name and clicked on Save Changes. (since i used custom url that’s why)

    You just saved me a ton of headache…

  25. Clive Wales

    That was a real life-saver – thought I’d totally screwed up a replacement site I’ve been working on, after trying to be clever with an .htaccess redirection. Thank you!

  26. Marko Liuksiala

    Great, that worked – thank you!!

  27. Bill

    I like the permalink structure of my posts and they seem to work. I have been using the same structure for several years.
    However when I go to Settings–>Permalinks the actual structure is not even listed as one of the options available anymore.
    Is this a problem?

  28. Emily

    Hi I am having this problem and to be honest, I feel sick because I don’t know what to do. I am a novice really and scared I am going to kill my website more than I already have.
    Can someone please tell me what my custom permalink should look like and what I SHOULD hav in my .htaacess file? Right now it seems blank?

    • WPBeginner Support

      Go to Settings » Permalinks choose a permalink structure that you like and then save your changes. Open your .htaccess file and you will notice that WordPress has automatically updated it. If it is blank and your chosen permalink structure is not working, then you can manually add this code into your .htaccess file:

      # BEGIN WordPress

      RewriteEngine On
      RewriteBase /
      RewriteRule ^index\.php$ – [L]
      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteCond %{REQUEST_FILENAME} !-d
      RewriteRule . /index.php [L]

      # END WordPress

      Administratör

  29. Viktor

    Yes, that was the solution! Thanks a lot. My hosting service changed these settings as I changed the URL to custom error pages but just clicking on the permalink settings fixed that.

  30. Matthew Shelton

    ”Go to Settings » Permalinks, and simply click on Save Changes button” – fantastic, that worked right away – thanks a lot!!

  31. Gretchen Louise

    What about for a single post permalink that got changed and somehow created an internal redirect, and now it cannot be changed back without creating a 404 error? Trying to troubleshoot an issue for a client and wondering where those internal redirects are stored and where in the world to clear them. Thank you.

  32. Thembi Ngema

    Dudessss. You guys are legends :)…. Must say I have learnt a lot from you in the past week :)

  33. bhupendra

    hi
    thanks I just updated parmalinks structure and site started working

  34. Arpee Lazaro

    i just updated t he permalink structures are pictured in this solution and it worked like a charm. thanks!

  35. Attiq Haroon

    I tried the solutions you mentioned in you post bhut it didn’t seems to be working. What happened actually is that I wanted to add a rule to .htaccess file so I downloaded that files from FTP and edited it and uploaded that file again replacing the original one, and then the problem popped up. I have tried a couple of fixes such as deleting and putting new .htacces with default code, removing .htacces file, etc. The only fix that is making the posts accessible is to set the permalink to default option. This makes the posts to work but it can not be a permanent Fix as it is not recommended as an SEO prespective
    Please try to find a working solution on that problem

    • WPBeginner Staff

      backup your .htaccess file. Then delete the one from your server. Now log into WordPress admin area and go to Settings -> Permalinks choose your desired permalink structure and hit save changes.

      After that connect to FTP and see if WordPress has created a new .htaccess file and it is not blank.

      • Attiq Haroon

        I tried that solution, It created a .htaccess file which looks fine but doesn’t work.

  36. gui

    If you have Yoast WordPress SEO or any SEO plugin installed, check your SEO permalink section…

  37. Tim Topham

    Hey guys – I recently received an email from Google crawl as I suddenly had a heap 500+ of lost links. It seems that at some stage I must have changed the permalink structure so that lots of the links on old posts have the post date and then post name where as they now just have the post name.

    Before I go mad trying to fix 500 links in my articles manually, is there an easy way to update the hyperlinks in articles when this sort of thing happens?

    Cheers,
    Tim.

  38. Manuel Moreira

    I was going insane with this 404 thing after a server move. Thanks for the help guys.

  39. Cindy

    thank you! My sites were hacked and all internal pages showed a 404 error. saving the permalink settings fixed it! cheers!

  40. Joe Cutroni

    Hi all, I’ve scoured the web to find help to resolve my issue, but
    for the life of me cannot get anything to work. Starting just a couple
    of weeks ago, all of my back end pages (home page was fine) started
    turning out 404 errors on them.

    The permalink that I have always used is ”Custom structure” (/%category%/%postname%/)…here are some things that I’ve tried:

    1 . Gone into my permalinks, clicked ”save settings”, and that method provides a temporary fix, maybe for an hour or two, then the 404 errors return on all secondary pages. I’ve also set my permalinks to a different option, such as ”Default”, but still get 404 errors shortly after.

    2. Completely deleted my htaccess.php file, then went back and saved permalink settings…less than an hour later, 404 errors returned.

    3. Commented out this line of code in my function.php file, also completely removed it altogether:

    ”$wp_rewrite->flush_rules();”. That didn’t do anything. I’ve tried
    using both ”//” and ”#” before it and tested…still get 404 errors.

    4. De-activated all of my plugins to see it one of them was the culprit,
    but after a short time, my 404 errors resumed while none of the plugins were active.

    Like I said, this issue just start a few weeks ago. I use Securi
    Security and had them scan my site for any malware, etc…and the site
    is clean.

    Can someone PLEASE help me with this? Would bigtime appreciate it!

    • Kyle

      Hey Joe,

      Did you ever find a workable solution for this? I’ve gone through the same issues that you listed.

      • David

        Hey Guys!
        Did you find a solution to the returning 404-error as listed above by JOE CUTRONI?
        I’m dealing with the same issue?

        Some Feedback would be awesome!
        Thank you!

        Greetings from Germany,
        David

        • Paul

          Hey guys,

          you are likely to have a virus on your site.

          good luck
          Paul

  41. Katie

    This is the problem I am having. I moved from Wordpress.com to .org and I am at my wits end. I understand the directions that say got admin—> settings —> permalinks. In fact, I remember when I was setting this up that I messed with that particular setting. Here’s my issues: WHERE do I find this admin–> settings–> permalinks?? Is it on my host, in the cpanel? Is it back on WP.com, or if it’s WP.org? And if it’s on WP.org I don’t have a clue how to get to all the admin features of my blog now. When I log in, it shows me my personal profile and allows me to edit it. But not any blog administration. I am at a loss and really losing my head.

    • Gabriel

      If I’m understanding you correctly, just type in the domain name that you activated the wp.org tool and follow it up with ”/wp-admin” (for instance ”www.example.com/wp-admin”)log in and on the lower left hand side you would find the settings option.

    • mali suresh

      how can change localhost paramalink step by step help me

  42. Srihari K

    I had the same problem.. adding the below line in httpd.conf and restarting apache fixed it.

    Options +FollowSymLinks

  43. Kym Penrose Clayton

    Thank you thank you thank you :D

  44. Iris Fritschi-Cussens

    THANK YOU from the bottom of my heart! I had to delete my .htaccess file due to a hack and then just when I thought everything was fine again nothing worked apart from the home page. Pressing Save Changes on the permalinks solved it in one.

  45. disqus_Hct2NXneXJ

    Thanks Man. The Permalink Solution Fixed my Problem. Thanks & Cheers for You!

  46. MEMEME

    Thanks! You are God.

  47. L

    thanks! I was close to panic…

  48. Thai

    Thanks for the post! But sadly I tried these with on the local and nothing worked.. Any other tips?

  49. SemLavana

    Thank you. Saved my weekend! :-)

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.