国产欧美日韩第一页|日本一二三不卡视频|在线精品小视频,亚洲第一免费播放区,metcn人体亚洲一区,亚洲精品午夜视频

WordPress模板如何使用SSL(https)外鏈

2017-02-10 14:33:29 13111

方法1:使用wordPress HTTPS插件解決外鏈問(wèn)題。

(1)wordpress后臺下載名稱(chēng)為“wordpress https(SSL)”的插件;

blob.png

(2)啟用https插件,然后測試https訪(fǎng)問(wèn);

blob.png

方法2:修改wordpress配置文件解決外鏈問(wèn)題。

(1)修改wordpress配置文件,添加以下幾行代碼:

$home = 'http://'.$_SERVER['HTTP_HOST'];

$siteurl = 'http://'.$_SERVER['HTTP_HOST'];

define('WP_HOME', $home);

define('WP_SITEURL', $siteurl);

修改后如下:

blob.png

(2)修改數據庫ssl_options表中siteurl和home的option_value值均為:“/”。

blob.png

(3)修改wp-includes/post.php文件,修改函數wp_get_attachment_url為如下代碼:

function wp_get_attachment_url( $post_id = 0 ) {

  $file_dir=dirname(__FILE__);

   $server_root=$_SERVER[DOCUMENT_ROOT];

   $file_dir=substr($file_dir,strlen($server_root));

   $file_dir=substr($file_dir,0,-12);

   if($file_dir!=''){

       $file_dir='/'.substr($file_dir,1);

   }

   $post_id = (int) $post_id;

   if ( !$post =& get_post( $post_id ) )

       return false;

   $url = '';

   if ( $file = get_post_meta( $post->ID, '_wp_attached_file', true) ) {

   //Get attached file

       if ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) {

       //Get upload directory

           if ( 0 === strpos($file, $uploads['basedir']) )

           //Check that the upload base exists in the file location

               //$url = str_replace($uploads['basedir'], $uploads['baseurl'], $file);

               //replace file location with url location

               $url=$file_dir.'/wp-content/uploads/'.$file;

           elseif ( false !== strpos($file, 'wp-content/uploads') )

               //$url=$uploads['baseurl'].substr($file,strpos($file, 'wp-content/uploads') + 18 );

               $url=$file_dir.'/wp-content/uploads/'.$file;

           else

               //$url = $uploads['baseurl'] . "/$file";

               //Its a newly uploaded file, therefor $file is relative to the basedir.

               $url=$file_dir.'/wp-content/uploads/'.$file;

       }

   }

   if ( empty($url) )

   //If any of the above options failed, Fallback on the GUID as used pre-2.7, not recomended to rely upon this.

       $url = get_the_guid( $post->ID );

   if ( 'attachment' != $post->post_type || empty($url) )

       return false;

   return apply_filters( 'wp_get_attachment_url', $url, $post->ID );

}

(4)登錄wordpress后臺,確認多媒體中圖片的鏈接為相對路徑; 

(5)并在已經(jīng)使用這些資源的文章、主題頁(yè)面圖片中重新插入此圖片,或修改為與多媒體中圖片一致的相對路徑;

         外觀(guān)中重新添加圖片或修改為相對的圖片路徑;

(6)排查其他地方是否有使用多媒體資源,按照以上方法調整即可。


提交成功!非常感謝您的反饋,我們會(huì )繼續努力做到更好!

這條文檔是否有幫助解決問(wèn)題?

非常抱歉未能幫助到您。為了給您提供更好的服務(wù),我們很需要您進(jìn)一步的反饋信息:

在文檔使用中是否遇到以下問(wèn)題:
-->