WordPress Broken Images - wordpress

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.

Related

wordpress site url wrong on local machine

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.

Wordpress migration and htaccess file

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

Wordpress Permalink Custom Url /index.php/%postname is working while /%postname is not working

I have uploaded my website to the server and when i am trying to change permalink, it is working only with /index.php/%postname.
Neither /index.php/%postname/% is working nor /%postname/* is working.
Thanks in advance....
put below code in .htaccess file in wordpress site directory. verify similar code is already present in .htaccess file or not. If present please replace with below code. if no .htaccess file is present please create one with following code.
# 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

non-wordpress files in wordpress installation directory

I have installed wordpress in root directory. There is a file say test.html in same directory. I can not open this file www.mysiet.com/test.html with this url. When i open this file i get 'No posts found'.(I have coded wordpress's template on my own and this message is in index.php if no posts found). so my questions are:
How can i open an html file that is placed in root directory.
Can i create a new folder in root directory and install another wordpress site in that directory while root directory already have a wordpress installation.
Can i create a new folder in root directory (that already has wordpress installed in it) and place some files in that new directory and access them via my browser.
Thanks
Open your .htaccess in the root folder which once opened should look something like this
# 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`
Then add this above all of that and place your directory in designated spot "replace
with subdirectory name" you can add as many subs as you like
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/REPLACE WITH SUB DIRECTORY NAME/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/REPLACE WITH SECOND SUBDIRECTORY NAME/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>`
Final Result should look like this if my subdirectory was named other
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/other/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
# 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`
If I understand this you have wordpress installed on your server in its own folder, something like www/wordpress/. You also have a *.html file stored in www/test.html correct?
If I'm on track, then the issue is when you configured this you would have told it to use the wordpress directory. The best solution is to either move that file into the www/wordpress directory or into its own directory off that one, so you could have www/wordpress/test.html or www/wordpress/tests/test.html.
For question 2 I think what you are asking is can you do something like www/wordpress/ having a wordpress site, but then www/wordpress/wordpress2/ having another site. Though this is possible it isn't the best idea, why would you want to do this? You should have www/wordpress/ and www/wordpress2/. If the sites are connected in some way, you should look into wordpress mu, which is a multi site, which will allow you to run many sites all from the same installation.
Question 3 was answered above but yes you can do something like www/wordpress/tests/test.html.
You may need to change your .htaccess rules if you want to be able to access html files under your wordpress install.
You can check for File Permission.

Configuring WordPress .htaccess to view subfolders

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

Resources