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. Laxmi Prasanna

    thank you very much. you saved my day. god bless you

  3. chandan

    you save my day

  4. Alessandro Morotti

    Thxs a lot man.

    Your save my job!!!

    congratulations by your time

  5. Niketa

    Many many Thanks.. I was worried first but your blog fixed my 404…as I was having exactly same issue.

  6. Abhishek Sharma

    Sir i dont know how to thank you.. But today you saved my life.. I was so scared. I just published a post and then when i checked that in my browser it showed 404 error then i check another post and then all . i was surrounded by 404 errors except my homepage was working. Now before posting to wordpress forums i just googled it and found solution on your website.,..
    Mannn Thanks for saving my life.

    • WPBeginner Support

      Hi Abhishek,

      We are glad you found this article helpful. Don’t forget to follow us on Facebook for more WordPress tips and tutorials.

      Administratör

  7. Richard

    Hi !
    I doesn’t work for me.
    i added ” . ” for prefix category but i fall in a 404 page when i try to access to my subcategory :s

  8. CR

    Awesome! It helped.

  9. Paola

    I LOVE YOU! I didn’t knew how to fix this I’m a complete novice. Thank you thank you! !

  10. Marlena

    I’m so pleased to have found this article first. I’m a complete novice and I fixed my own 404 issue.
    YAY!
    Thanks so much!

  11. Saud Razzak

    Very informative and useful article for WordPress beginners!

    • Eri

      Please can you help me for this, because I tryied but i cant fix it :/

  12. Tom C

    Great guide! Totally solved my issue.

  13. Anil

    I have created a subdirectory. And I have two wordpress installed, one in root and the other in subdirectory. Both of them contains posts and pages. I want to access both and it’s happening. But when I am hiding the subdirectory slug from the post URL by modifying the .htaccess file, the sub directory name got hidden as per the requirement but the posts of my main domain is inaccessible and getting 404 error. I want to access the post from both root as well as subdirectory. Please suggest.

  14. Jawad

    Thank you very very much for your help

  15. Farukh Hussain

    Thanks alot for sharing. Your tutorials always helps me.

  16. Karen

    Thank you so much for this!

  17. Grant Turner

    Fixed. My problem was since I’m running on a windows server then I don’t have a .htaccess file. I need to create a web.config file.

  18. Cindy Martin

    This fix DID NOT work for me! I still have a 404 error on my blog page only. I am using Gridalicious and have had nothing but trouble! (Not with Gridalicious but other stuff too).
    I removed everything from the to start over. loaded the theme and get the error.

    Blog posts are not showing up on the blog page except in the widget and the main page is the 404 error message. Saving permalinks does nothing at all. Host is GoDaddy. HELP! I’m really tired of all this and frustrated.

  19. Maranna

    Thanks! I moved website from one server to another and had the problem with posts returning 404. Main page and admin were working fine. Re-saving permalinks worked to fix this problem. Seems that this setting is not carried over correctly in all cases.

  20. Aondongu Tivzenda

    The permalinks fix worked perfectly. Thank you for this website. Awesome!

  21. alvin

    My problem is funny. I have a couple of WP websites I am currently running each logged into one browser with different portals and logging user names. After I noticed the 404 error checking the redirect area i see my author names have been mixed up from all the different websites. Can someone please assist

  22. niranjan

    It worked! Thanks!!

  23. Vishwa

    It worked! Thanks!!
    Yours is a great website!

  24. Charley Gordon

    Thanks for sharing your knowledge.

  25. Al

    Thanks, worked for me :-)

  26. Mayapur Voice

    This post saved my day today! In an attempt to fix a long standing problem today our host changed the .htaccess file. The issue got resolved but it broke all my links. By the grace of God, I found this post in an instant and it was exactly what I needed. Thanks tons!

  27. marcela bonadio

    exactly what i needed. thanks for sharing your knowledge.

  28. Casey

    Hello, thanks for this article and all the other awesome articles I have found on wpbeginner. I am running into some problems with my front page giving me an ”oops! That page can’t be found” error. I am wondering if you have any advice on how to fix it.

    I am running:
    LAMP with Debian 3.2.84-1 x86_64 (Wheezy) on a VPS, Apache 2.2.22, php5
    Wordpress: 4.7.1
    Theme: YS Magazine

    The original issue occurred when I switched the permalink structure to use ”post type” instead of the default. At that point I could no longer view any of my pages and just got a 404 error. So, I did some research and edited my .htaccess file to allow overwrite. This fixed the problem of the 404 errors on all my pages, except on whatever page is set to my home page. To be clear, there was no problem with any of the pages before I changed permalinks. It also does not matter if I set the front page to static or posts. If I change my front page to another page I can then see the page which was set previously as the front page, but the new front page then gives me the error.

    I have tried:
    disabling all my plugins and enabling them one by one
    changing themes
    changing the .htaccess file back
    changing permalink settings

    I have been searching for an answer to this for hours now and seem to have ran into a brick wall. Any help would be super appreciated. Thank you so much.

  29. Bart Dority

    Thank you so much for this post!

    I knew my 404 errors had something to do with the permalink structure – and I even tried changing the permalink structure and saving it – and otherwise updating and refreshing it — but it still wasn’t working. But then I read this post which said — instead of changing the permalink style and saving it, — just leave it where it is, and click Save anyway. That worked for me. A huge relief. Thank you!

  30. Angelica

    Thank you so much!! It worked!!

  31. MarcB

    Thank you so much for this help. Really a lifesaver.

  32. Elyes Gherib

    Thank you very much, this did it for me!

  33. Z

    Thanks for the post. I’ve had to deal with other problems after switching hosting providers, but this was a new one.

    I did the method provided and my site was back to normal within seconds.

  34. Kristine

    Hello, I am hoping you can help me- I am super nervous about my wp site right now. When I type the address into the search engine it is a completely barebones site that says it is ”set up through Wix” that no longer looks like our site we have been operating through wordpress. This just happened out of the blue and I am so nervous about our posts.

    • WPBeginner Support

      Hi Kristine,

      It seems like your WordPress site’s domain is hosted by Wix. If you have login details for a wix account, then you can login and point the domain to your current WordPress hosting provider. If you are unsure, then please try contacting Wix support and your WordPress hosting provider support for more help.

      Administratör

  35. Jolene

    Thank you! My blog has been down and I couldn’t figure out how to fix. In a last ditch effort before I call customer support…I googled. You saved the day!

  36. Bruno Almond

    Great blog here! Additionally your site rather a lot up very fast! What host are you the usage of? Can I am getting your affiliate link in your host? I desire my web site loaded up as fast as yours lol

  37. AJ

    great job mate, you did a better job than the tech support at bluehost

  38. Lorene

    No, this worked for the one post that was showing Error 404, but then ALL the others that worked before, now show Error 404. So I had to change it back. Hope most of them work now.

  39. Gabe DeFrates

    Excellent tip for fixing the permalink! I was getting the ”File not found” error, and I went right into the WP Control Panel Settings, Saved Changes and she’s working again. You saved the day! Thank you for your time in posting this.

  40. Samnang Thorng

    Thanks I can deal with site now. Great helps

  41. jhonny

    Recently I have changed my site permalinks and now i am getting lots of 404 errors i have redirected them some of them to new url and others to homepage but still my site users were going down and down what to do now help me please should i change them back to old permalinks? or something else to do please tell me

  42. Exxagon

    Thanks a lot for your post.
    Since many weeks, I was stucked with a 404 error each time I tried to change my permalinks structure.
    I found the solutions in your post :
    1. Modify /etc/apache2/apache2.conf, and set ”AllowOverride All” everywhere instead of ” AllowOverride None”
    2. Empty /var/www/html/.htaccess completely, change it to www-data:www-data & set it temporary to 777.
    3. And the main one : ”sudo a2enmod rewrite”, and ”service apache2 restart”

    Thanks again !!
    Xavier

    • Asif

      thanks bro it help me and my server version is working fine now

    • Suraj

      Thanks a lot… It’s working for me.

    • Erwin

      Hey, where can I find ”/etc/apache2/apache2.conf”??? I don´t even know where to search? Do I need a special Application or something? Sorry, i´ve no idea : I

      • Abel

        Hi, “/etc/apache2/apache2.conf” is a Ubuntu system folder. If you want to access it, you should have access to your server (like ssh).

    • Abel

      Thanks a lot!

  43. Vinita

    Recently I am getting lots of 404 page errors in google webmaster. While revamping my wordpress website, instead of redirecting old urls to new, I just edited existing urls to new ones. e.g. website.com/url1 was edited to website.com/url2. Now webmaster if giving 404 error for old urls i.e. website.com/url1. How am I supposed to solve this error? (there are almost 155 urls with 404 errors so cant ignore)

  44. Sandy

    Is there a plugin that can find 404 errors and redirect them safely with best SEO tactics? Or should i do a edit find and replace in my xml file and remove the urls?

    appreciate your ideas…

  45. Michael

    changing the right to 660 made my site unavailable. i had to set .htaccess to 644 (which was the original setting). regards Michael

  46. Swadesh

    Thanks a lot :)

    Its working for me.

  47. Kieron Atkinson

    I’m running wordpress on a client’s in-house server and even though the htaccess file is there with the rewrite module sequence, permalinks are still not working. In fact all the URLs are coming up as example.com/index.php/permalink.

    How do I check if the module rewrite is enabled on the server? My client says that they have that enabled but it still doesn’t work.

    Many thanks for your help.
    Kieron :)

  48. Renee

    Mahalo nui loa (thank you very much)!
    Reassigning the Permalinks is exactly what was needed after moving 10 sites to a new hosting company.

    Abundant blessings to you and your team.

    • WPBeginner Support

      Hi Renee,

      Glad you found it helpful and thanks for the kind words. You may also want to join us on Twitter for more WordPress tips and tutorials.

      Administratör

  49. Steve

    Thank you for your well written article. I have logged in to both /wp-content and /wp-includes/ and I havent found my .htaccess file.
    Is it possible that I dont have one as I also get the 404 error if i try and redirect a page usin Redirection in WP.
    Thanks in advance.
    Steve

  50. Paras

    hello
    i am facing this same problem
    i tried your method but still its showing error

  51. Margarita

    Today I was about to launch my web after 5 months working very hard in localhost. I was very happy but exhausted. While doing all the migration process, my site was gone. I had made a backup of course, but after trying a hundred times nothing worked. All seemed lost… until I found your post and it was solved in less than 30 min.

    My day has been awful, a waste of many hours and energies. But now I go to bed with a smile in my face. Happy again. Infinite thanks.

    Marga Rubio Soto

    • WPBeginner Support

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

      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.