网站优化

网站优化

Products

当前位置:首页 > 网站优化 >

导入wordpress网站

GG网络技术分享 2025-03-18 16:12 4


问题描述:

Someone gave me a wordpress website (files and sql dump), I imported the database into mysql and the files onto my ftp.

I modified the site and home url in the option table and opened the website.

The index page is fine but any link I click returns a 404. So I thought about .htaccess and tried the default one:

# 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

But now instead of 404 I have a text like that:

Login

mysitename

How can I know what\'s the problem ?

网友观点:

I finally found a solution:

  • in the template-loader.php file I commented out do_action( \'template_redirect\' ); which solved the 404 error for url like domain.tld/index.php?page_id=123 but not for formated url like domain.tld/cat/title
  • as it gave me access to admin I verified the site url in the settings and saved. - I also modified permalink style and saved several times (it didn\'t work first time)

Now it works

###

You can open the exported SQL file in an editor and find/replace every instance of the previous URL with the new URL (i.e. http://www.example2.com replacing http://www.example1.com. Then transfer it again to the server.

In addition you have to edit the server and connection settings in the wp-config.php file

ADDITION:

And another thing, an old WP bug which keeps coming: After doing all that just go to the \\\"Permalinks\\\" page in the backend once. Somehow this (i.e. just opening that page) resets the permalinks settings which otherwise sometimes are broken.

标签:

提交需求或反馈

Demand feedback