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:
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
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.