之前用 WP Offload Media Lite plugin 蠻開心的,但移機發現竟然產品的 url 沒有跟著匯出。
有發現一篇可能可以解決的方法,但有點麻煩而且怕不小心誤砍了資料庫就更糟糕了。
最後還是花錢升級成 pro,有一個功能會將移過去的圖片上傳到 S3。
不知道還有沒有其他解決方法? 看來要等人 support 了
最近在轉換網站,遇到幾個坑,紀錄一下。
1. plugin 無法背景更新,或是一些 AJAX 的程式不能順利執行。查了一下 /var/log/apache2/error.log 看到一些神奇的錯誤訊息 " AH01630 Client Denied by Server Configuration: ... wp-admin/admin-ajax.php",解決方法是修改 Apache 的目錄設定,把 AllowOverride All 改成 AllowOverride None
reference: https://linux.101hacks.com/unix/client-denied-by-server-configuration/
2. 在執行 FTP 相關指令時失敗,錯誤訊息如
PHP Warning: ftp_nlist() expects parameter 1 to be resource, null given...
PHP Warning: ftp_pwd() expects parameter 1 to be resource, null given in...
PHP Warning: ftp_rmdir() expects parameter 1 to be resource, null given in...
要修改 wp-config.php,將 define('FS_METHOD','direct'); 放在 require_once ABSPATH . 'wp-settings.php'; 之前就可以了。
reference: https://wordpress.stackexchange.com/questions/365737/ftp-nlist-and-ftp-pwd-warnings
3. 今天在刪除使用者時,發現有 wp cli 這樣的指令列,不過在安裝完畢之後需要先設定 wordpress 目錄才會好用。
$ wp plugin status --path=/path/to/wordpress
refence: https://stackoverflow.com/questions/61275895/wp-cli-how-to-get-set-path
把沒有交易過的使用者刪除,可以用這個。
4. 要增加新商品沒問題,但網址列有 index.php 很醜,因此要用permalinks 把 .htaccess 修改路由規則。但如果發現 .htaccess 沒有生效的話,可以從 phpinfo() 看 mod_rewrite 是否有載入? 沒有的話就用sudo a2enmod rewrite 安裝吧。
reference: https://wordpress.stackexchange.com/questions/105795/remove-index-php-from-permalinks
5.如果修改 .htaccess 之後一直出現 Forbidden 403 Error,可以將 Options +FollowSymLinks 放在 .htaccess 最前面,或是在 Apache 目錄的設定加上去。
reference: https://coolestguidesontheplanet.com/403-forbidden-error-wordpress-htaccess/
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl'); UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl'); UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
DocumentRoot "/path/to/www" <Directory /> Options FollowSymLinks AllowOverride All Require all granted </Directory>
DocumentRoot "/path/to/www" <Directory /path/to/www> Options FollowSymLinks AllowOverride All Require all granted </Directory>
sudo chown -R www-data:www-data wordpress
if (method_exists($wpdb, 'esc_like')) { $term = $wpdb->esc_like(esc_sql($term)); } else { // Compatibility for pre-4.0 WordPress $term = like_escape(esc_sql($term)); }
318 body, input, textarea { 319 color: #373737; 320 /*font: 15px "Helvetica Neue", Helvetica, Arial, ans-serif;*/ 321 font: 15px "微軟正黑體", sans-serif; 322 font-weight: 300; 323 line-height: 1.625; 324 }
383 blockquote { 384 /*font-family: Georgia, "Bitstream Charter", serif;*/ 385 font-family: "微軟正黑體", sans-serif; 386 font-style: italic; 387 font-weight: normal; 388 margin: 0 3em; 389 }
393 blockquote cite { 394 color: #666; 395 /*font: 12px "Helvetica Neue", Helvetica, Arial, sans-serif;*/ 396 font: 12px "微軟正黑體", sans-serif; 397 font-weight: 300; 398 letter-spacing: 0.05em; 399 text-transform: uppercase; 400 }
<pre lang="LANG"> // code here </pre>可用的LANG在langs目錄下都查得到, 於是乎範例就像
<pre lang="c"> #include <stdio.h> void main() { printf("Hello World"); return; } </pre>