Wordpress does not support relative paths, which is not conducive to access by multiple domain names. How can I enable wordpress to operate in a relative path?
You can log on to the backend-setting-options and set the wordpress url, otherwise, the system will ask you to reinstall wordpress. After confirmation, the wordpress url column is empty, but in the database, the value of siteurl is "/".
The above method is no longer available in the new version of wordpress, so people want to directly modify the corresponding field in the database as "/". This seems to work in many occasions.
However, the absolute path must be used according to the wordpress logic. Many of its functions use the home and siteurl variables. Simply change their values to "/", which leads to a high possibility of problems. A better way is to follow the design logic of wordpress access by absolute path and try another method.
This method is actually very simple, that is, first determine the access domain name, and then assign this domain name to the home and siteurl two global variables. The specific method is very violent is also very simple, do not change the database, just need to add the following statement at the end of the wp-config.php:
<? Php
$ Home = 'HTTP: // '. $ _ SERVER ['HTTP _ host'];
$ Siteurl = 'HTTP: // '. $ _ SERVER ['HTTP _ host'];
Define ('wp _ home', $ HOME );
Define ('wp _ siteurl', $ SITEURL );
?>
After this modification, the setting-options page in the background can only be displayed, but the home and siteurl values cannot be modified because they have been defined as two constants ), they are completely displayed based on the access domain name.
This method not only enables wordpress to access the content of the entire site in a "relative path" mode, but also conforms to the design logic of wordpress's tangled absolute path. It should be the best solution. However, it should be noted that after this modification, the path of the media files such as the image inserted during editing is still an absolute path. After insertion, You need to manually change the Domain Name of the path to remove it.
This article is from the "structured thinking" blog, please be sure to keep this source http://yuanxi.blog.51cto.com/2149074/980913