Wordpress blog enable second-level domain name for image acceleration

Source: Internet
Author: User
Tags file url subdomain subdomain name wordpress blog

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 /';

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.