Early website planning is very important. Many websites divide static resources and dynamic pages, such as img, by domain name. Here, we use wordpress as an example. We also support uploading all the graphs to a second-level domain name, such as img.361way.com. Then we can use varnish or third-party acceleration.
1. Modify options. php
The custom Upload path function is hidden in versions later than wordpress 3.5. However, you can modify the path by accessing http: // url/wp-admin/options. php. After opening, find "upload_path" and "upload_url_path"
"Upload_path" and "upload_url_path" correspond to "default Upload path" and "complete file URL ". The "default Upload path" ("upload_path") option sets the upload path. If the sub-domain is in the same directory as the main site, it is recommended to use the physical path. The "complete URL address of the file" ("upload_url_path") sets the image display path, that is, the reference path. It is generally the address of the subdomain name. If there is a directory under the subdomain name, you can fill in the corresponding address under the subdomain name, just like this.
II. Change the image address
After the final settings, you can check the library to see if all the referenced addresses of the images have been changed to their own addresses. At the same time, upload the images and try again to see if they can be uploaded to their own locations, if there is no problem, copy all the images in the original Upload Directory of the website to the sub-domain directory. You can run the following SQL statement for replacement:
The code is as follows: |
Copy code |
UPDATE wp_posts SET Post_content = REPLACE (post_content, 'http: // www.111cn.net/wp-content/uploads/', 'http: // img.361way.com /');
|
3. Modify the editor for Upload
Taking the KindEditor editor as an example, it also comes with the image upload function.
Find the following file and modify the following two lines:
The code is as follows: |
Copy code |
# Vim wp-content/plugins/kindeditor-for-wordpress/php/upload_json.php Find $ Save_path = $ php_path. '.../uploads /'; $ Save_url = $ php_url. 'Uploads /'; Modify it: $ Save_path = '/opt/img /'; $ Save_url = 'http: // img.361way.com /'; |