Redirect htaccess localhost to IP - php

I'm currently working on a wordpress website using WAMP locally, I've got the site working fine on another local computer, however images aren't showing they're simply appearing as localhost/wp-content/etcetc instead of 10.0.1.2/wp-content/etcetc
CSS and everything else loads fine. Obviously the images load fine on the host computer, however I'm looking to setup so can work from LAN based machines too.
I figure htaccess would be a simple(ish) fix, if I at all knew what I was doing.
Basically could anyone point me in the direction of a htaccess code to directed localhost to 10.0.1.2 please?
Thanks!

The question you are asking is not the correct one - you do not want to change localhost to point to a specific private IP address or you will have issues with an unknown number of other things.
To properly correct the issue you will need to go through the process of Moving WordPress - updating the URLs in the options, postmeta, and posts tables. This can also be achieved by exporting the contents of your site to an XML file, doing a search and replace on this text document (change localhost to 10.0.1.2 or whatever host name you want), and then re-uploading it. You will need to update the site_url and wp_home values as well.

Follow the steps:
Go to Dashboard > Settings > General
In the 'WordPress Address (URL)' and 'Site Address (URL)' labeled text boxes replace the word 'localhost' with your IP address.
Save changes.
This solves your problem.

Related

Wordpress Website is being redirected to another link

I created a website on WordPress on the domain "https://new.fulldigitalnews.com/" and then I uploaded the files and database to another domain "https://bsengworks.com/" and also I put the URL correctly in the database.
But still when I open "https://bsengworks.com/" it is redirected to the previous domain "https://new.fulldigitalnews.com/"
Help me with it.
database wp_option SS
even user URL is correct.
Tried removing the wordpress installation from Cpanel. And I re-installed it and created again but it is being redirected again.
You may have to configure the DNS setting. I have never used WordPress as a host but have used other hosts and tried doing similar stuff eventually, I just contacted the host support, and they walked me through changing a bunch of DNS values. Not sure of your exact situation with WordPress, but I would just contact them and see if they can help.
It doesn't redirect for me.
Have you tried it in a different/private browser?
It's possible the old URL is cached in your browser and it's sending you to it incorrectly.
you have to change links in database wp_options table in two rows. First row contains option_name="home" and other option_name="siteurl" and change link in both rows then it works.

wp-login.php redirects to server site, not locahost

I downloaded all the wordpress files from the server.
And imported the database phpmyadmin locally.
And I can enter the site local. But when I do:
http://localhost:8080/nieuwdenhaag/wp-login.php
Then I don't see the login page of localhost. But I will be redirected to de admin of the server site.
So are there are some files that I have to change, except of course the wp-config file?
Thank you
There are two ways to solve the issue
You can change the siteurl and home fields from your database according to your local address (http://localhost:8080/nieuwdenhaag). In that case, you've to go phpMyadmin > select your database > select wp_options table and then change. Please see the attached image to understand properly.[![siteurl and home fields][1]][1]
You can add the two constant in wp_config.php file.
define('WP_HOME','http://localhost:8080/nieuwdenhaag');
define('WP_SITEURL','http://localhost:8080/nieuwdenhaag');
Thank you
[1]: https://i.stack.imgur.com/DTHHr.png
Not 100% a WordPress expert but I did have to do something similar to this recently to migrate a site and also get it working on my localhost to fix a few bugs. What I did was use this plugin (https://en-ca.wordpress.org/plugins/all-in-one-wp-migration/) to export -> to a file and then import it on your localhost!
Hope this helps.
After download the complete site from the live server you have to change the url in the database in the options table. The parameters are siteurl and home. After that you should be able to login to your admin.
In Wordpress all URLs are stored directly in the database. You have to search a plugin that replaces your URL in the database that you can see all files (Better Search Replace) for example.
You can use the following search and replace script for that.
https://interconnectit.com/search-and-replace-for-wordpress-databases/
It has a nice UI using which you can update your URLs. This will also update the URL in various plug-ins metadata.
Don’t forget to delete the script after using it.

Change Base link of website using .htaccess file

can editing .htaccess file. Base address of site for all link on home page will changed?
scenario:My osclass hosted at openshift cloud with url http://myappdomain.rhcloud.com After adding alias at server side i am using www.mydomain.com with forwarding masking feature.Everyting is fine for home page.But poblem is when user click on any link on website.Browser URL field change from www.mydomain.com to http://myappdomain.rhcloud.com/link instead of www.mydoamin.com/link.but if user manually type www.mydomain.com/link it works and it remain same not changing to http://myappdomain.rhcloud.com/link in browser URL. Hover over links also show http://myappdomain.rhcloud.com/link not www.mydomain.com/link
i even try to edit config.php file
define('WEB_PATH', 'http://www.mydomain.com/');
but it is not working. my point is can this acheive with editing .htaccess file with minimal effect or there some other way. Have anyone try openshift for osclass before with custom domain? wordpress and osclass are quite similar in architecture.Have wordpress users on openshift face such problem?
Please note that .htaccess only changes the way server handles visitor's request. It does not change the contents in your web site. Therefore, you can never change your "hover result" with .htaccess settings.
I think that depends on how the links are generated in your website:
If the links are stored along with HTML in database, you'd need to change it with database query. If you're using MySQL, please learn your database structure and form a correct REPLACE query.
If the links are generated on-load, please make sure you flush all the caches. Cache may not know that your WEB_PATH has changed.

Images problems in WP when I import the website on my local web server, why?

I am pretty new in WP (I came from Joomla) and I have the following problem trying to import an old WP blog (made using WP 3.5) on my local web server.
I have put the old blog foder into my www Apache directory and then I have imported the database on my local MySql DB.
After, I went into the wp_options DB table and I have change the value of the option_value field related to the rows home and siteurl putting in them the correct address (on my localhost web server)
Ok, it's seem to work fine: I can see my website and the articles on it but now I have the following problem:
If an article contains an image, I can't see this image and if I open it in the browser, I get the the following error message: 404 Not Found
Not Found
The requested URL "/it/wp-content/uploads/2012/10/Andrea-Alfieri-chef-bassa3.jpg" was not found on this server.
And in the browser address bar I have the following wrong URL:
http://www.myOldWebSite.it/it/wp-content/uploads/2012/10/Andrea-Alfieri-chef-bassa3.jpg
It is wrong because it is related to the old website URL and not to my localhost website.
I think that must be some wrong settings on my database and that I have to change it but I don't know what I have to change
Can you help me? Some ideas?
Tnx
Andrea
Three things to try. change settings->permalinks to default - you can change it back later.
also in settings->general there is a fields called Wordpress Address and Site Url
then open your db.sql file in a text editor like sublime text or notepad++ and do a search and replace of the old url to the new local url. Then re-import the edited db.sql file into the the database on the new host.
This has worked for me in the past when moving WP from one host to another.
In database in table of posts (example: wp_posts ) guid is the url of specific image
you can update this table :
UPDATE wp_posts SET guid = replace(guid, 'http://www.old-domain.com','http://localhost');
I hope to help
You seem to know what your doing in terms of migrating your blog.
I would assume that if you went in to the settings->general section, both the URL's will match the new URL of the local server. Judging by what you have mentioned in the question.
Providing when you access the blog and then access the Dashboard the URL remains that of the local server then ,most likley everything is as it should be.
Another thing you can try which I have done before to resolve issue when migrating is to use the Wordpress search and replace plugin. This simply checks all tables for any instances of the old URL and replces this with the new one.
Make sure to backup the database before using this tool. Here is the URL for the plugin.
http://wordpress.org/plugins/search-and-replace/
Hopefully this will be of some use to you.

Help with Clean URLs

I am very new to php (in fact about 2 days old). After getting ripped off by my last webhost I have decided to move my website to a different host. A friend has been helping me do this as he has a little info but we are now stuck and I have tried finding a soloution on google but most answers are way over my head. My site is a php site with a mysql database. We have moved the database and ftp'd the site and everything is now working on the new server except one thing - my site was designed originally to use clean urls? When I go to my shop page (ie: mywebsite.com and click on the shop link - mywebsite.com/shop/ (shows in the bottom left of my browser) I get a page not found error, yet when I type in the url mywebsite.com/shop.php the page displays fine. In addition, if I go to mywebsite.com/shop/shoes/ (another link which shows the preceding link in the bottom left hand corner) I get a page not found error. Also if I type in mywebsite.com/shop/shoes.php in the address bar I also get a page not found error even though the page shoes.php exists on the ftp server in a folder called templates - if I go to mywebsite.com/templates/shoes.php it shows up) I understand this is called clean urls and I need to add an .htaccess file to sort out the issue. I have looked on the ftp area of my old host and cannot find this file but have been told it is probably hidden. I have been told by my new provider that mod-rewrite is available on the server but I have no idea how to write this htaccess file. Can anyone please give me a step by step on how to do this as I am not a coder.
Additional Details
I have the following files in my root directory: index.php, shop.php, checkout.php, completed.php, contact.php ... I then have a folder called templates and in this folder I have: shoes.php. clothes.php, coats.php ...
The issue I am having is that most of the php files in my root directory already have href-links? pointing to places like mysite.com/shop/ and mysite.com/shop/shoes/ so when I open up the home page in my browser and hover over the links these are the addresses I see and when I click on the links I get page not found as the borwser must be looking for the links in the wrong place. (these links worked fine however on the last host I used). I understand I need an htaccess file to re-direct these links to the correct places. - ie the link for mysite.com/shop/shoes/ is actually linking to a page called shoes.php located in root/templates. I understand this method was used to tidy up the urls?? ie: instead of having mysite.com/templates/shoes.php the urls shows mysite.com/shop/shoes/. I have looked at the code within some of the php pages in the root and they all have lots of links to these 'false' addresses - ie: mysite.com/shop/shoes/ when the actual file should be at mysite.com/templates/shoes.php. I don't want to go through each file one at a time as they are hundreds of links, thus the reason for trying to make this htaccess file. Thanks for your time, Dave
Try to find an option on your FTP client software to show hidden files.
The name of this file is .htaccess (dot htaccess), that is probably the reason you're not seeing it. If the old site is working then the file is probably there. You could also contact somebody to send you the file via e-mail, IM, etc.
You do not need mod_rewrite or .htaccess for this.
Turn on multiviews in your Apache configuration. This will allow you to omit the .php extension from your URLs.

Categories