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
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
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');
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.
Related
I am trying to move my WordPress site from local to live. In my case homepage is working fine, but while migrating to next page or other menus it shows 404 error. I have changed my .hdaccess file and permalink settings. But it is not working. can anyone give a clear solution to this problem?
My existing .hdaccess file is
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /bookExperts/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /bookExperts/index.php [L]
</IfModule>
# END WordPress
I have changed my .hdaccess as given below
# 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
You need to go to table wp_options and change site_url and home with your new domain name.
after this go to sql tab in phpmyadmin and run below code
UPDATE wp_posts SET post_content = REPLACE(post_content, '{old_domain}', '{new_domain}');
this will fix broken links & images.
Follow these steps.
settings > permanent links > save changes
it's all
Before migrating you must have changed the url:
settings > WordPress address (URL) / Site address (URL)
I don't know what can cause this problem, but my WordPress web-site after migrating to new server is not showing me images. It is maybe something in .htaccess file, rewrite rule or something. Any directions please?
Please click here to see my page.
.htaccess from public_html directory:
# 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
.htaccess file from wp-content/uploads:
# BEGIN alti-watermark Plugin
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*(-([1-3][\d]{1,2}|[\d]{1,2})x300|-300x([1-3][\d]{1,2}|[\d]{1,2})|-([1-1][\d]{1,3}|[\d]{1,3})x1024|-1024x([1-1][\d]{1,3}|[\d]{1,3})|-940x446)\.jpg|.*(?<!-\dx\d)(?<!-\d\dx\d)(?<!-\dx\d\d)(?<!-\d\dx\d\d)(?<!-\d\d\dx\d\d)(?<!-\d\dx\d\d\d)(?<!-\d\d\dx\d\d\d)(?<!-\d\d\d\dx\d\d\d)(?<!-\d\d\d\dx\d\d)(?<!-\d\d\dx\d\d\d\d)(?<!-\d\d\d\dx\d\d\d\d)(?<!-\d\d\d\dx\d\d\d)(?<!-\d\d\d\dx\d\d)(?<!-\d\d\d\d\dx\d\d\d\d\d)\.jpg){1}((\?|\&)([^\.\?\ ]+))*$ ../plugins/alti-watermark/public/views/alti-watermark-public-bridge.php?imageRequested=$1 [PT]
</ifModule>
# [date=2016-12-27 18:06.57] [php=5.4.45] [width=300x300|1024x1024|940x446|fullsize] [plugin_name=alti-watermark] [version=0.3]
# END alti-watermark Plugin
Thanks in advance!
Usually that's because file paths are saved as absolute paths in the database.
In this case you either need to get some plugin that changes all those filepaths for you (see https://wordpress.org/plugins/search/migration/ for resources) or export your database as a mysql file, open it in an editor and do a search/replace to replace all old filepath instances with the new one, and then import that again in your database.
I need to migrate a wordpress from http://myoldwebsite.com/blog to http://newwebsite.com/.
I have htaccess file as follows. Am I right if I change
RewriteBase /blog/ to RewriteBase /
RewriteRule . /blog/index.php to RewriteRule . /index.php
My .htaccess code.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
Just use a migration plugin, like WP Migrate, to export the DB.
After you are done with the DB import, don't forget to go to Settings->Permalinks and just hit save button, in order to have .htaccess updated.
Done.
Unfortunately it's not as simple as just changing the .htaccess file.
From the Wordpress codex:
When your domain name or URLs change - i.e. from
http://example.com/site to http://example.com, or http://example.com
to http://example.net - there are additional concerns. The files and
database can be moved, however references to the old domain name or
location will remain in the database, and that can cause issues with
links or theme display.
The most important change which most trips up a lot of people is to change "siteurl" and "home" in the "wp_options" table to point to your new address.
Yes you can add the following to htaccess file. If you are migrate a wordpress from http://myoldwebsite.com/blog to http://myoldwebsite.com/
# 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
Note You have to change URL in database also.
If you want to migrate a wordpress from http://myoldwebsite.com/blog to http://newwebsite.com/. You can use followin plugin to migrate
Plugin link
I have import on my local webserver a backup of a website made using WordPress but I am finding some difficulties with PermaLink configuration
The main problem is that if I use the permalink setted as Article Name I can see the homepage but if I click on the articles links into the homepage (to see the article) I always obtain the following message error:
Not Found
The requested URL
/wordpress35/2012/10/11/se-milano-avesse-il-mare-anzi-no-la-montagna-di-campiglio/
was not found on this server.
If I instead I use the Default settings for permalink (http://localhost/wordpress35/?p=123) I have no problem and I can access to the articles in my website
I think that this is a .htaccess problem. Can you help me to create an .htaccess file that solve this problem?
My actual .htaccess file is:
# 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
I need to use the URL format described as: http://localhost/wordpress35/my-article-name
Did you try creating a the wordpress .htaccess for your needs?
# 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
This should work if you didn't specify any change in the website's URL.
(If the homepage is still http://localhost/wordpress35/ )
I have a WordPress installation with an .htaccess file that looks like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I tried installing a fresh copy of WordPress into a subdirectory for a separate blog and am getting 404 errors within the root WordPress when I try to view it. I'm assuming this is because of the .htaccess file.
How do I change it so that I can view the subfolder?
For future reference, you may want to try this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog2/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog2/index.php [L]
</IfModule>
# END WordPress
Edit#2: ok i think i figured this out, but it's pretty messy.
modify your base wordpress install's .htaccess file to look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/blog2/.*
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
now, load a new copy of wordpress into "blog2/", and copy your wp-config.php file over to it. edit the "/blog2/wp-config.php" file and change the $table_prefix to something different than your first blog. (this will install both wordpresses into the same database).
once you've done that, you should be able to go to:
http://yourdomain.com/blog2/
and finish up the installation without issue. the initial problem was that the new copy of wordpress kept trying to use the first copy's wp-config.php file. moving it over manually fixed that all up.
because i'm insane, i tested this with two fresh copies, wrote a few test articles, and was able to navigate around without issue, so it should work :)