Moving from http to https, and www. to non-www URL

Add the following to your .htaccess.. # force https on the front of the site RewriteEngine On RewriteCond %{HTTPS} !=on RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ref https://stackoverflow.com/questions/4398951/force-ssl-https-using-htaccess-and-mod-rewrite if on nginx the advice is for the following.. server { listen 80; server_name yoursite.com www.yoursite.com; return 301 https://yoursite.com$request_uri; } refer to http://www.wpbeginner.com/wp-tutorials/how-to-add-ssl-and-https-in-wordpress/ for other areas such as the … Read more

get_template_directory_uri cached?

Caching is not your problem here. The home URL and site URL are stored in the wp_options table in your database. You can update them either by visiting the Settings > General page in your WordPress dashboard, or you can edit the siteurl and home option values directly in the database through an SQL query … Read more

WordPress URL redirect

This is quite possible. First off, Making pagename/{customString} resolve as the page itself instead of 404, then, you’re free to decide whether to keep the URI as is and serve the page content, or redirect back somewhere e.g page permalink ( get_the_permalink() ): add_action( “init”, function(){ $pagename = “pagename”; // page slug add_rewrite_rule( sprintf(‘^%s/([^/]*)/?’, $pagename), … Read more

Wrong wp-admin URL

Eventually, I found the reason of this weird behaviour. It is caused by the JavaScript embedded in wp_admin_canonical_url() (https://developer.wordpress.org/reference/functions/wp_admin_canonical_url/) The URL is determined by this piece of code $_SERVER[‘HTTP_HOST’] . $_SERVER[‘REQUEST_URI’] where the latter one returns wp-admin instead of hello/wp-admin. By manipulating the value in $_SERVER[‘REQUEST_URI’], I can successfully get the correct behaviour in admin … Read more

When clicking on “home” page from any other page, it goes to IP address and my website doesn’t load

The URLs are greyed out in the Settings page because of the entries in the wp-config.php file. If there are entries for these values, those values override the values in the wp-options table, and the override makes the Settings values uneditable. See this in the Codex: https://wordpress.org/support/article/changing-the-site-url/ It is possible to set the site URL … Read more

How to set “Site Address (URL)” programmatically on WP multisite?

If you just want to update that one value, then you can use wp_update_site(): wp_update_site( 123, [ ‘domain’ => ‘new-slug.domain.com’, ] ); But to really update the site URL/address, you’d need to update both the siteurl and home options for the site: switch_to_blog( 123 ); update_option( ‘siteurl’, ‘new URL here’ ); update_option( ‘home’, ‘new URL … Read more