admin管理员组文章数量:1404579
I have self hosted my wordpress today, but I realised it is still having static link of my local installation, since now I am opening using my IP (as i haven't done DDNS yet) i want that link should change to IP followed by ret of the URL instead of static local url.
Any help would be greatly appreciated.
I have self hosted my wordpress today, but I realised it is still having static link of my local installation, since now I am opening using my IP (as i haven't done DDNS yet) i want that link should change to IP followed by ret of the URL instead of static local url.
Any help would be greatly appreciated.
Share Improve this question asked Oct 9, 2016 at 17:11 Ciasto piekarzCiasto piekarz 1092 silver badges7 bronze badges3 Answers
Reset to default 0If I'm understanding your question correctly, you want links on your site to dynamically change depending on the domain name of the environment you're in?
To do this you can replace any hard coded links with the home_url()
function.
So you would change references to links from http://192.168.0.1/your/path/here
to <?php home_url(/your/path/here); ?>
If your links were defined through the Wordpress Admin UI then you'll need to use filters or change all the links via an option in Settings. Refer to this question for details: https://stackoverflow/questions/22014167/general-wordpress-link-filter
I am happy that i would suggest you with some strategies so that you may find which one is useful and make use of it as per the scenarios that you are pertaining to it.
Solution One:
Bit Easier with the help of the plugin in WordPress.
Plugin Name: Relative URL
Plugin URL: https://wordpress/plugins/relative-url/
Description: Relative URL applies wp_make_link_relative
function to links to convert them to relative URLs.
Solution Two:
How to Make Internal Links Relative in WordPress
Reference: I have found out a very easy and worth example so that you can follow it up and you can make the static links to relative on the fly.
https://www.webhostinghero/how-to-make-all-internal-links-relative-in-wordpress/
Solution Three:
An another Stack Overflow Answer that is found very useful when using relative URL is as follows:
Question: Relative URLs in WordPress
Solution: https://stackoverflow/questions/17187437/relative-urls-in-wordpress
Solution Four:
Another Informative posts that i have found to be is the below link and it is very much superb in order to make the relative URLS.
Reference: http://www.deluxeblogtips/2012/06/relative-urls.html
Hope so any of the methods will be useful and you may crack the hindrance that you have using these four methods on the fly.
Happy Coding :)
I guess you need to simple set your web server IP in wp-config.php like this:
define('RELOCATE',true);
define('WP_HOME','https://11.22.33.44');
define('WP_SITEURL','https://11.22.33.44');
And try if you don't have the web server problem.
curl -I https://11.22.33.44
and if you access the
curl -I http://11.22.33.44
is it forwarding properly...
Important! Leaving the RELOCATE constant in your wp-config.php file is insecure, as it allows an attacker to change your site URL to anything they want in some configurations. Always remove the RELOCATE line from wp-config.php after you're done.
Resouce https://codex.wordpress/Changing_The_Site_URL
本文标签: phpchanging static link to relative link
版权声明:本文标题:php - changing static link to relative link 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744833512a2627490.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论