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!
Larry
Hi,
I have moved my two domains from a web hosting service provider to another web hosting service provider. The new web hosting service provider setup WordPress websites from the cPanel. Only the homepages are loading correctly but the other webpage links are showing Server Error 404 Page Not Found.
The webhosting service provider told me to update my permalinks and the web.config code. I updated the permalinks to show ”post name”. I don’t know how to update the web.config code. From watching these videos, I see that I should update the htaccess file. However, my htaccess do not show any missing text and it contains identical as shown in your video. What next should I do?
Many thanks.
Joe
My problem is, I moved my blog to a self host. And changed my permalink to ”post name” Ever since then,
1. I noticed my traffic start reducing,
2. Couldn’t get searches from Google/yahoo/bing linking to my blog again.
3. Got a lot of broken links.
What do I do please?
I’ve started getting discouraged with this..
WPBeginner Support
Hi Joe,
You can change your permalink structure to whatever it was before by visiting Settings » Permalinks page.
Administratör
David
Thank you very much! This tutorial was very helpful.
Bert Ramirez
Worked like charm…THANK YOU!!
Tejash
Thanks so much. I was able to resolve the error
prakhar
when i try to see plugins it gives 404 error.
add plugin is working fine but i can’t get to plugin.php when i try to see
installed plugins.
also update-core.php also gives 404 error.
what could be the reason?
jeff
Hi,
I have the same problem. I couldnt able to install a plugin which is this ”themify-wc-product-filter.zip” .i always get file not found error 404 as result. can anyone help me out please? thanks guys in advance
Marisol
Hey thank you work for me took me 2 minutes to fix it!
Sjoerd
Hi,
I have the same problem. The first solution worked for me, just now wordpress somehow keeps getting back tot the 404.
So i click save changes, it works again. And then a few minutes later the 404 error is back. Anyone any ideas?
Thanks.
Kind regards,
Sjoerd
Ravi J
I have the same issue too….
1) Changed Permalink
2) Manullay created the .htaccess file
3) removed and created the site once again
Amy help is greatly appriciated
Note: I am setting up a local instance in Ubuntu 16 LTS.
Biggles
I have a similar problem: I moved hosting providers and now my WP login box is top left hand corner of my browser screen and, most critically, when I login, every page and link for WP gives me a 404.
The website loads fine for my visitors but I am unable to gain access myself in WP. Well, I am, I can log in, but that’s all I am able to do. After many years of web design, this is a first.
I have done the following:
1. deleted the .htaccess file
2. tried an old .htaccess file
3. created a new .htaccess file
4. changed the name of some and all of the plugin folder names via ftp to see if there’s an issue with a plugin
FYI, that I was unable to load my sample website (subdomain) after the migration, and all that was showing was a ’database error’ white screen. I finally managed to track down the issue, and I was a little bit upset about it: in my new cPanel, I noticed the username had disappeared next to the database name, and when I tried re-entering it again it wouldn’t take it because I had been limited to only a few characters in length. I created a new username and updated the config file, and it works okay now.
So, I opened my new cPanel and my previous cPanel side by side and my old host didn’t restrict me on database username character length, whereas my new host did to about 7 or 8.
…so, I’m starting to think that even though all of my other subdomains and client websites are now all loading fine, that it may be that a different version of cPanel and how my new hosting provider has set it up has affected how I interact in WP for my failing website.
v. 68.0.23 new cPanel
v. 66.0.34 old cPanel
Do you think there is an issue with how my new host has setup WHM and / or cPanel.
Many thanks in advance : )
Wen
Hi there, i did other test and the error show everytime, so any ideas??
Afroze
for me, after going nuts, i had to enable the rewrite module… i forgot to do this when I migrated sites.
in ubuntu:
sudo a2enmod rewrite
Wen
Hi guys!
I’ve tried everything and its shows still the error in my links, can you help me?
WPBeginner Support
Hi Wen,
If you are seeing 404 errors on just few pages, then you can try setting up redirects to fix them.
Administratör
Wen
The problem is in all the links except the home…. and i did everything except redirect…
Hank Wilson
Thanks for this, permalinks idea worked. Bookmarked for future reference
Alan Ross
Thanks for the fix. Worked like a charm !
Fahad Siddiqui
I tried this .htaccess code but the error remains same as ”Not Found
The requested document was not found on this server.”
TJ
I am wondering if this would fix my admin login page? Keeps showing 404 error and not the login page. I don’t have issues with a 404 error on pages and post. I think it might be conflicting plugin I’m using called Hide MyWp, but they told me its working and reset the settings anway and said it’s beyond their plugin control.
WPBeginner Support
Hi TJ,
Try steps mentioned in our WordPress troubleshooting guide. It will help you figure out what’s causing the issue and how to fix it.
Administratör
LaVonne Carlson
Thank you! This worked for me. I did have to change the Common Settings from ”Custom Structure” to ”Post name”, but once I did that my blog came back.
Nick
I followed your instructions, but I still get the “white page of death” with my posts. Is there a way to actually remove “index.php”?
WPBeginner Support
Hi Nick,
The index.php file is crucial for your WordPress site to work properly. If you think it is causing the issue, then you can download a fresh copy of WordPress, unzip on your computer, locate the index.php file and upload it to your website replacing the old file.
Administratör
Malik aadil
Thanks so much
It helped me to solve 404 error problem
srinivas
i dont know how to thank you…it really helps and solved my problem…thanks ….lovely post
Demari
Thank you so much for this!
Christina
Thank you very much! Your help solved the problem!
Rafi ullah
Hi every one..
i have a website which is working properly but when i login to admin panel and want to edit a page it show me a error that ”page not found” but in the front end it look fine this error show only on editing time ..
please help me i am stuck
Thanks in advance
Jeremy
THANK YOU SO MUCH! I’ve tried everything else thinking it was a timing error. You saved me lots of time.
Thank you again!
Serguei Kireev
didn’t work for me. installed Yoast SEO, noticed it defaulted to weird permalinks with /index.php/ in them, went to change that to normal way – no more permalinks for me… only works via ?p=123
mudi
Hi, you guys are great it’s work for me
elham
Thank you so much!!!!
Vikash
Thanks, Its worked perfectly.
Karen Holst
You guys are the best!
I always find your tutorials to be just what I need to update/fix my WordPress site!
Regarding the 404 not found issues, I had some template pages (I purchased a WordPress theme from a vendor and had some live pages hidden that I wasn’t using) that were getting indexed that I didn’t want indexed. So I changed the pages to ”unpublished” in WordPress.
I ran an analysis on indexability and now all those pages are showing ”404 Not Found” errors.
Do you all suggest a way to keep these pages from being indexed altogether? What is the best practice for fixing something like this?
Thank you again for all the great work you all do!
WPBeginner Support
Hi Karen,
You can set up redirects for those pages. See our guide on how to setup redirects in WordPress.
Administratör
Shahidul Islam
Thanks So much! It works great!
Azizul Haque
Thanks, This worked for me too!
Mark Quinn
Many thanks. This worked a treat.
vishnu
Hi
please help to fix the following.
while submitting a comment in my webpage its working properly but after 3 or more submission it showing 404 page not found
how can i fix this problem without using a plugin.
Munesh Dagar
wow,
this is very helpful.. my website is not not load page cause of URL not found
i am go to permalinks & select other links & again i selected postname & save settings my website is work properly
zhivko
The update in Settings Permalink worked perfectly for me.
danny
I had the problem with the permalinks and fixed the issue by saving as a plain permalink then saving as custom permalink. that worked but I am having a problem with the permalinks issue again. i fixed it by doing the above step again. is there a way to avoid it happening again. thanks!
Milos Mitrovic
Hello guys,
I have the same problem, some pages appear as ’not found’ but they are present in wordpress. Check this one:
I have updated permalinks but it didn’t work.
I wouldn’t dare accessing my FTP and would like to know if there is any other way to change it? I use hosted wordpress.
Thanks
WPBeginner Support
Hi Milos,
We will suggest that you update .htaccess file using FTP or File Manager in cPanel.
Administratör
Jheel
Hey,
I am getting error for rest of my pages , excluding the home page. The images & the videos are not visible. I have done all the required steps. Kindly help me out.
jora
same probleme did you find any solution yet ? Thank you
Kimberly
Thank you so much!! Flushing the rewrite rules worked.
Hemant Pandey
It helped. Very nice. Can you suggest best permalink structure? Also how to get social counts back after changing permalink structure?
Himaja
I am trying to add the wordpress blog as a subdirectory in nginx server. Added blog under cakephp/app/webroot/blog . Main page works fine but not the post links and sublinks. Shows not found error. I tried your post but no result. Can you please help me to sort out this?
Thanks.
Mike
Hello, I tried just about everything
1. Deleted and uploaded new htaccess file
2. Checked robots.txt
3. Checked sitemap
4. Disabled all plugins
5. Checked google console
6. Checked to see if my site is blacklisted
Google will not communicate with my site all at.
I only get ”403 forbidden error”. I couldn’t even verify my site ownership with google until I verified through the ”cname card”.
During 1 test I did get a ”200 server error”. Please help
Lucky
Many thanks for you help. It worked my site is back.
Jill
Hello! I downloaded the htaccess file and copy/pasted. I am still getting the 404 errors on my blog. Not sure what else to try. Any ideas?
Thank you,
Jill
Dias, Wesley S.
THANKS!!!!! Very much.
sam
where is .htaccess?
Phoks
not work same probleme halp me please
tauseef shah
thank you so much buddy, it really help me
robert
worked. thanks.