WordPress站点链接失效且无法登录后台求助
Hey there, let's work through this WordPress issue together—this is a super common headache when launching or updating site URLs, so we'll get it sorted out.
First: Regain Access to wp-admin
The main hurdle right now is getting back into your admin dashboard. Here are two reliable ways to fix the URL mismatch:
Edit wp-config.php (Quickest Method)
Connect to your server via FTP or cPanel File Manager, find thewp-config.phpfile in your site's root folder, and add these two lines right above the/* That's all, stop editing! Happy publishing. */comment:define('WP_HOME', 'http://projekts.dk'); define('WP_SITEURL', 'http://projekts.dk');This forces WordPress to use your new URL for both the front-end site and the admin area, bypassing the database settings temporarily. Save the file, then try accessing
http://projekts.dk/wp-adminagain—you should be able to log in now.Update the Database Directly
If you can't edit wp-config.php, use phpMyAdmin (via your hosting control panel):- Find your WordPress database, then locate the
wp_optionstable (your table prefix might be different if you changed it during setup). - Look for rows where
option_nameissiteurlandhome, then update theiroption_valuetohttp://projekts.dk. - Save the changes, then try logging into wp-admin.
- Find your WordPress database, then locate the
Next: Fix All Broken Site Links
You mentioned trying a MySQL search-replace but it didn't work—this is usually because WordPress stores some data as serialized arrays, and plain text replacement breaks that formatting. Here are safe ways to fix this:
Use WP CLI (Most Reliable for Developers)
If your hosting supports WP CLI, run this command in your site's root directory (replaceold-urlwith your previous site URL, e.g.,http://localhost/your-siteor the old domain):wp search-replace 'old-url' 'http://projekts.dk' --all-tablesThis command automatically handles serialized data, so it won't break any settings or content.
Use a WordPress Plugin (User-Friendly)
Once you're logged into wp-admin:- Install and activate the Better Search Replace plugin.
- In the plugin settings, enter your old URL in the "Search for" field, and
http://projekts.dkin the "Replace with" field. - Check all tables in the "Select tables" section.
- First, check "Run as dry run" to preview changes (make sure nothing looks off), then uncheck it and run the replacement.
Final Step: Clean Up & Verify
- After replacing links, go to Settings > General in wp-admin and confirm that both "WordPress Address (URL)" and "Site Address (URL)" are set to
http://projekts.dk. Save the settings—this will update the database properly, and you can remove the lines you added to wp-config.php if you want. - Clear your browser cache, and any server-side cache (like CDN, Redis, or caching plugins) to make sure the new links load correctly.
- Test a few pages (like your Kontakt page) to confirm links are working now.
内容的提问来源于stack exchange,提问作者James Blue

