Change Base link of website using .htaccess file - php

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.

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.

WP-Admin redirects to old URL (after editing config.php)

I am trying to get a client's WordPress site copied over to my company's server to use as a development site. I've ran into an issue when trying to log into the site's administrator panel; it redirects us to the existing site's URL instead (ending up as [OLD SITE]/[NEW URL]/wp-admin). Additionally, trying to go to any page other than the homepage gets a 404.
I've tried editing the wp-config and defining the WP_HOME and WP_SITEURL there, with no success. In a previous attempt we used a backup tool that was meant to replace references to the old URL with the new URL, and on another we ran queries and checked through wp-options in the database to be sure that we caught all of the old references. Still redirects to the old site.
We've tried restoring from two backups, Akeeba and BackUpWordPress. Our current attempt is a copy we've downloaded directly and then uploaded (with an imported SQL backup).
Another odd thing I've noted is that changing one of the URLs in the database causes more issues. Mainly, if I update the URL of 'wordpress-https_ssl_host' in the wp-options table, the theme breaks. Not sure where to go with this from here.
I'm always succesfully using the following script : search & replace:
https://interconnectit.com/products/search-and-replace-for-wordpress-databases/
in order to update a wordpress site url.
Just copy the provided code in a directory under your site, then launch the provided index.php in a browser: the database infos should be automatically determined. Then specify the old and new urls and click on "Run" !
Don't forget to remove the created directory afterwards.
For solving this issue you have to change siteurl in database wp_options table
option_name = siteurl where
option_value = YOUR OLD SITE URL
change your old site url and update it with your local developement site URL
Hope this will help you..
We found the problem; as it turns out it was nothing to do with anything from the default WordPress files. The client was using an extension called WordPress HTTPS, and apparently that was causing a conflict somewhere. We renamed the extension's folder to disable it and everything ran fine. I imagine it was overriding what we were setting in wp-config.

wp-admin can't access after moving

I need mention that I had google search the solution before post at here.
I move my wordpress site to another domain and different server.
wp_config.php edited; database, database username, passwword, and host all changed. table_prefix remain the same because i use the same one.
wp_posts and wp_option i had changed too.
I still got this error message anyway.
You do not have sufficient permissions to access this page
Anyone know what happen and how to fix this ?
wp-admin can't access after moving
If you are moving your domain without changing the Home and Site URLs of your WordPress site you can follow the below guidelines as prescribed by the wordpress codex.
If database and URL remain the same, you can move by just copying your files and database.
If database name or user changes, edit wp-config.php to have the correct values.
If you want to test before you switch, you must temporarily change "siteurl" and "home" in the database table "wp_options" (through phpMyAdmin or similar).
If you had any kind of rewrites (permalinks) setup you must disable .htaccess and reconfigure permalinks when it goes live.
EDIT (if your site url has also changed, well i am only phrasing from the codex site)
Moving a website and changing your domain name or URLs (i.e. from http://example.com/site to http://example.com, or http://example.com to http://example.net) requires the following steps - in sequence.
Download your existing site files.
Export your database - go in to mySQL and export the database.
Move the backed up files and database into a new folder - somewhere safe - this is your site backup.
Log in to the site you want to move and go to Settings > General, then change the URLs. (ie from http://example.com/ to http://example.net ) - save the settings and expect to see a 404 page.
Download your site files again.
Export the database again.
Edit wp-config.php with the new server's mySQL database name, user and password.
Upload the files.
Import the database on the new server.
When your domain name or URLs change 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.
If you do a search and replace on your entire database to change the URLs, you can cause issues with data serialization, due to the fact that some themes and widgets store values with the length of your URL marked. When this changes, things break. To avoid that serialization issue, you have two options:
Only perform a search and replace on the wp_posts table.
Use the Search and Replace for WordPress Databases Script to safely change all instances.
Make sure that the web server is allowing you to view the page itself, and look in the httpd.conf or .htaccess file for the directory that the main Wordpress script lives in.
Make sure that the Wordpress files have the correct permissions. If you just copied them over, then the user that needs to accesses them (apache on many typical LAMP installs, but yours may be different) is able to.
If you have already copied all your files and moved all of it to the new directory, then all you need to do is set your site url, home url.
So for example, if you are working on wordpress locally, you might have had your original URL to something like this:
http://localhost/wordpress
and your new URL might be something like this:
http://wordpress.local
In the case above, you would need to modify your settings in the database.
Database settings:
Go to the wp_options table, and look for the column named option_name, look at the field that says siteurl and home. You will notice that next to them in the option_value field you had your old URL. Change this to your new URL, and you should be good to go.
Hope this helps.

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