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.
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
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.
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.
Om ingen av dessa lösningar fungerar, gå vidare till nästa metod där vi troubleshootar dina permalänk-inställningar.
Metod 2: Fixa 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”.
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”.
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”.
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.
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)”.
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.
Hitta sedan alla instanser av AllowOverride None
och ändra dem till AllowOverride All
.
Värdet ”All” innebär att alla direktiv kan åsidosättas.
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.
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!
taher
My problem is a little different i do have access to my wp-admin, But i am unable to access to any page within wordpress, including dashboard or settings and re-directed to 404-error page. I have disabled cloudfare, but the problem persists.
WPBeginner Support
If the method in this article is not working you may want to try the general troubleshooting steps in:
https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/
to see if it is due to a specific plugin or theme.
Administratör
sikkandhar
great help, by just changing theme of wordpress, my 404 errors solved,
thank you for simple and great idea.
WPBeginner Support
Glad our guide could help
Administratör
Oswaldo
Thanks for this amazing solution. I have a membership site and when i looked up to my mail this morning i have a lot of users that wrote that the cant access to the page because is showing the 404 error message and in fact this was happening, i didint know what to do, i thought it was some plugin or some function i put the night before….
Then i found this post, i saved again the permalinks as shown in this post and WORKED!!!
but i am not happy yet, i want to know why happened this problem? so this wont repeat again because all night while i was sleeping this problem happened
please can you tell us, why happened this problem, so we can avoid this?
Thank you
WPBeginner Support
Sadly, it is difficult to say the root cause. It could have been an update from the host’s end or something on your site could have updated your permalinks incorrectly as some possibilities.
Administratör
Lina Jin
I checked .htaccess and permalink settings too but its still not working.
In pages, I can see only some pages and others show errors.
’Trying to get property ’post_author of non-object in C:\xampp\htdocs\aaa\wp-admin\incldues\class-wp-posts-list-table.php on lline 1180’
So the page links are not working and after login, the homepage is automatically redirected to wp-admin and dashboard shows nothing.
Can you help me with this?
WPBeginner Support
You would want to start with the general troubleshooting steps in: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/
You could also try updating your WordPress files using the method in: https://www.wpbeginner.com/wp-tutorials/how-to-manually-update-wordpress-using-ftp/
Administratör
Harry
Thank you for this tutorial, solved my problem.
WPBeginner Support
Glad our article could help
Administratör
kaleab
i had the same problem geting 404 error in post.php …it was frustrating but the only thing worked form me was change the the theme..and change it again…it worked for me………..
WPBeginner Support
Thanks for sharing what worked for you
Administratör
TrigienIT
i had the same issue. tried the options above but they did not work until I also changed the theme to another, then reverted back to the normal theme.
José
None of the solutions worked for me. I can only acces to my home page, any other link like pages & post are not working. The update that caused this was the 5.0.3
WPBeginner Support
To ensure this is not a conflict with a theme or plugin you would want to take a look at this article for steps to try: https://www.wpbeginner.com/beginners-guide/beginners-guide-to-troubleshooting-wordpress-errors-step-by-step/
Administratör
Nikki S
Wheew! This DID work for me. All I had to do was hit the Save button. So thankful for the article.
I just updated to WP 5.0.2 yesterday from 4.9.8. Could that have been the cause? It seems to run fine yesterday.
WPBeginner Support
As with any technology, there are many possible reasons. It could have been the update, a hiccup with the host, or another unknown reason.
Administratör
Anjalai
am working in wordpress admin suddendly it showing 404 error message. so what am to do and i am beginner for wordpress
WPBeginner Support
You would want to follow the steps in this article and should none of them work, reach out to your hosting provider and they should be able to assist.
Administratör
Okan
Thanks thanks thanks. You are the man!
Mike
Thank you so much. It worked. My site is fully back online. Thank you.
WPBeginner Support
Glad you found it helpful
Administratör
RKapunan
Thank you so much. My links are back!
Jennifer Nelson
Thank you!!!!
Daniel S
I have tried all the suggestions from the article and some from comments.
Then I contacted my hosting company and it turned up that their ModSecurity module on the server blocked POST requests with ”+src=” string in it.
It could be different rule for you but if everything else fails try asking your hosting company to check if any request was blocked at the server level.
zak
thank you so much you are amazing, i love you so much, you are great, i searched a lot of pages and no one knows and teaches like you. you are awesome.
Thank you Thank you Thank you
Matzi
Thank you. It worked perfectly.
jay
this is happening to our site almost monthly and the only way to fix is to reset the permalinks in wp dashboard. debug log file is clean so i dont have any clue where to start fixing. any one having the same problem?
Ronny
I have the same problem! but I do not know where the problem comes from? does anyone know how to solve it?
Musab
Thaaanks many thanks
Arlene
My world was torn apart when I received this 404 error. Thank you WPBeginner for this helpful guide.
Jerry Bordadora
Thank you!! You save my me bro
Toyin
My issue has to do with the next page. I reduced the number of posts showing on my home page from 10 to 5, and when I click on the next page, it’s coming up with the 404 page not found
Aram
Hello! Thank You for interesting article! I have a little different problem. I want to redirect my 404 page to another, accurate and beautiful page. And normaly use plugins or template possibilities for that. But one of my sites, where there is the same template that I usually work with, the 404 page does not exist at all. Whatever I do. I get error telling that The requested document was not found on this server.
WPBeginner Support
Hi Aram,
Try updating your permalink structure. Simply visit Settings » Permalinks and then click on the save changes button without changing anything.
Administratör
Ann-Jeanette
I cannot put in words how grateful I am for this exact article. THANK YOU
behdad
extremely helpful thanks
Renan
Works like a charm!
Morcio
It works, thanks THAAANKS a lot!!
Zihad
Thanks for such an easy solution.
Okereke Divine
This article is actually very very helpful.
But my problem seems to be different. Please WPBEGINNER, you guys should please and please help me…
I have tried the methods above but its not working. though my problem is kindoff different.
My problem is:
Sometimes, When I try to update my previous post or make a new post.., it redirects me to ”404 error. Please and please help me.
WPBeginner Support
Hi Okereke,
Please try these steps. Go to Settings > Writing page and under the update services section delete any URLs in the box (Normally you will only see one URL rpc.pingomatic.com). Now click on the Save changes button to store your settings.
Try editing a post to see if this resolved your issue. If it didn’t then, please try steps in our WordPress troubleshooting guide.
Administratör
Lisa Cox
This article saved me so much time….I was ready to scrap the whole thing and re-do the blog from the start because I thought I had made an irreversible mistake. Two clicks everything is fixed – THANK YOU! Sorry, I didn’t mean to sound like Dr. Suess. Enjoy your day!
Daulat khan
Hi! This article was helpful but when i put my site on google search bar ex, ac-universal.com/wp-admin an error 404 found how can i enter into my word press.
Guied ne thanks
WPBeginner Support
Hi Daulat Khan,
Have you tried the .htaccess method described in the article?
Administratör
Mark Wayda
Just wanted to say thanks. Simple and effective fix for a problem that had been perplexing me for a few days!
joseph
thank you, this was very helpful
Khulu
Thank you Tom
Your solution works perfectly!!!!
Ash
Thanks. Your instructions worked 100%. It was driving me crazy.
Okereke Divine
Though my problem was that if i try to update my post., it redirects me to 404page.
I followed your instructions and it worked perfectly!
Collins
I can’t access my home page.
It keep saying 404 not found whenever i go to my url
Fernando Njaria
Thank you so much, had me going crazy with the 404 error, but after saving changes to the permalinks settings it worked!
Ibrahim Shabbir
I Cannot Even Access My Admin Page
Doni
That is my problem also. I can access my home page and one of the two top-nav pages, but I can’t access the second page, and I can’t get to /wp-login or /wp-admin.
Paulo
Awesome… saved my life, thank you
Tom
Great tips – for some reason, this didn’t completely fix my issue as AllowOverride was set to ’None’ in my httpd.conf file
Should anybody else run into the issues, simply edit your Apache2 httpd.conf file located in one of these locations: /etc/apache2/httpd.conf. /etc/apache2/apache2.conf.
Look for:
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
And replace with:
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
Hope this helps somebody!
Clinton
Thank you Tom,
I deployed a new site with Google One Click Deploy and missed some instructions about setting the AllowOverride All for the docroot directory. Your reply along with this article helped me get this working again. With AllowOverride set to None .htaccess files are ignored, so the directives to use make permalinks work, fail. In my case the config that I needed to edit was /etc/apache2/sites-available/wordpress.conf which had the directory of the wordpress install with the AllowOverride None set.
My Real Name
Thank you sir. You are my hero right now. I looked at so many sites and not a single one of them mentioned this. It wasn’t even obvious from the apache manual, to the extent that I read that.
Dipak Vasava
Thank You very, problem solved. its working code.
Simran
Thanks a lot..nothing to say. It really helped me. You done a great work..Thank you so much
Lagz
Worked like a charm, Thanks!
Contact form 7 Ajax was not working, giving me the feedback 404 error in console log.
I did not suspect rewriting rules until I read this.
Saving the permalink settings did the job!
Thank you
Favour
am confused, at the .htacess what I saw there was 0644 not 660, how do I go about it.
JP
Thank you for posting this- it saved me a ton of time- Cheers!
prabhat pandit
very helpful information for me
Richard
Thank you very much!!
Prabhat
thank you very much. for a moment i felt all my work is gone. you saved me
Sonja
Thank you!!! This was an awesome guide. Made my evening a lot better!
eriab nsereko
Thx WPB team, it worked like charm and that’s why I really love this mighty site!