0

I am maintaining a Wordpress website and want to set up it on my local machine. I have downloaded all the source code, dump database and restore the database. I also change siteurl and home on wp_options table to my local folder. The problem my local copy still points all the urls to the root folder instead of my folder (eg: http://localhost/wp-content/uploads/2019/06/img.png instead of http://localhost/mysite/wp-content/uploads/2019/06/img.png). Do I need to do something else to correct the url?

My htaccess files:

# 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
Lee
  • 1,041
  • 7
  • 20
  • 31
  • This will probably guide you in the right direction: https://stackoverflow.com/questions/50182457/images-not-showing-error-after-wordpress-migration-from-localhost-to-live-server – Alecbalec Aug 07 '19 at 05:46
  • RewriteRule ./mysite/index.php [L] .htaccess – Kishan Aug 07 '19 at 08:02

3 Answers3

3

I think your .htaccess file look this

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/index.php [L]
</IfModule>

# END WordPress
Kishan
  • 1,182
  • 12
  • 26
1

In your wp-config.php, try adding this code above // ** MySQL settings - You can get this info from your web host ** //

define('WP_HOME','http://localhost/mysite');
define('WP_SITEURL','http://localhost/mysite');
Pratik bhatt
  • 488
  • 8
  • 23
0

This htaccess code is correct.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /mysite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /mysite/index.php [L]
</IfModule>

# END WordPress

But also you need to replace path in database as well as of now you mention you only change path in wp_option table with your local path. But in other table like wp_post also have path with your domain name url where your site working like page , post, attachment path etc.

So batter you can replace path in database with your local path.

How you can do this ?

Just open exported database sql file with any text editor for example notepad++. Open find & replace dialog andd your old site your in find box & new local url in replace box then replace in full database and import that base and check.