Wordpress permalinks not working in Xampp/localhost server once migrated from Internet
Quote from HeelpBook on October 6, 2020, 9:18 pmI have an issue: I have migrated my Wordpress site from my web hosting on my system and imported in htdocs in Xampp.
The main site page is working, but when I try to access any link (permalinks) from there I got a 404 error even if I have imported and modified correctly the MySQL DB for localhost environment.
What's happening? How to fix that?
I have an issue: I have migrated my Wordpress site from my web hosting on my system and imported in htdocs in Xampp.
The main site page is working, but when I try to access any link (permalinks) from there I got a 404 error even if I have imported and modified correctly the MySQL DB for localhost environment.
What's happening? How to fix that?
Quote from HeelpBook on October 6, 2020, 9:23 pmUsually this kind of scenario happens when the .htaccess is present (and it needs to be present) but not modified for the new local path.
For example, if your project is located on:
E:/xampp/htdocs/my-site-backup/
Then you need to specify the path starting from the localhost.
E:/xampp/htdocs/ === localhost === /
To fix permalinks you will just need to change RewriteBase and RewriteRule in the .htaccess. If the following is the first version:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]# END WordPress
The following will be the new version (for localhost):
# BEGIN WordPress
RewriteEngine On
RewriteBase /my-site-backup/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my-site-backup/index.php [L]# END WordPress
Once the .htaccess will be updated, you will need only a page refresh (no Apache restart in Xampp is needed).
Usually this kind of scenario happens when the .htaccess is present (and it needs to be present) but not modified for the new local path.
For example, if your project is located on:
E:/xampp/htdocs/my-site-backup/
Then you need to specify the path starting from the localhost.
E:/xampp/htdocs/ === localhost === /
To fix permalinks you will just need to change RewriteBase and RewriteRule in the .htaccess. If the following is the first version:
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
The following will be the new version (for localhost):
# BEGIN WordPress
RewriteEngine On
RewriteBase /my-site-backup/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my-site-backup/index.php [L]
# END WordPress
Once the .htaccess will be updated, you will need only a page refresh (no Apache restart in Xampp is needed).