Diréktori Tulisan
Kusabab plugin Wordfence teu tiasa nyeken jalur domain anu sanés sacara aman, pikeun ngagampangkeun pamindaian anu aman ku plugin Wordfence, jalur subdomain gambar WordPress kedah dihijikeun kana folder domain anu sami dina situs wéb WordPress.
VestaCP sareng cabangna HestiaCP ngamungkinkeun pangguna pikeun ngaropea jalur diréktori folder domain.
Nanging, jalur folder subdomain dina panel kontrol CWP teu tiasa disaluyukeun pikeun dihijikeun kana jalur dina folder domain anu sami.
Contona, blog Chen Weiliang parantos dihijikeun kana jalur folder subdomain ▼
/home/用户名/public_html/chenweiliang.com
Lamun nambahkeun ngaran subdomain, teu éféktif pikeun ngabeungkeut jalur dina folder ngaran domain sarua ▼
/home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
- Jalur folder ngaran subdomain sapertos kitu teu tiasa ditambihan...
- Ieu solusina.
CWP custom subdomain ngaran folder prosés jalur diréktori
- Mimiti tambahkeun jalur polder nami subdomain (setel misah ti polder nami domain anu sanés):
/home/用户名/public_html/img.chenweiliang.com
- Teras, édit sacara manual file vhosts sareng ganti jalur diréktori folder nami domain ieu:
/home/用户名/public_html/img.chenweiliang.com
- Ganti ku jalur diréktori folder ngaran domain khusus di handap ieu:
/home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
Kumaha carana ngédit file konfigurasi vhosts di CWP7 tur ngaganti jalur diréktori tina folder ngaran domain?
Léngkah 1: Jieun diréktori polder khusus ▼
mkdir /home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
Léngkah 2: Salin file gambar ka lokasi folder khusus anu nembé didamel. ▼
cp -rpf -f /home/用户名/public_html/img.chenweiliang.com/* /home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
Lengkah 3: Lebetkeun Editor Konfigurasi WebServers sareng édit file konfigurasi vhosts domain Nginx sacara misah.
Klik "Edit" ngaran domain Nginx vhosts file konfigurasi▼
- Éditor Konfigurasi WebServers → Setélan WebServer → /etc/nginx/conf.d/vhosts/ → Édit

/etc/nginx/conf.d/vhosts/img.chenweiliang.com.conf/etc/nginx/conf.d/vhosts/img.chenweiliang.com.ssl.conf
Lengkah 4: Ganti jalur diréktori folder ngaran domain ieu ▼
/home/用户名/public_html/img.chenweiliang.com
Ganti ku jalur diréktori folder ngaran domain khusus di handap ieu ▼
/home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
Lengkah 5: Pareuman heula layanan nginx ▼
systemctl restart nginx
Lengkah 6: Lebetkeun Editor Konfigurasi WebServers sareng édit file konfigurasi vhosts domain Apache sacara misah.
Klik "Edit" ngaran domain Apache urang vhosts file konfigurasi▼
- Éditor Konfigurasi WebServers → Setélan WebServer → /usr/local/apache/conf.d/vhosts/ → Édit

/usr/local/apache/conf.d/vhosts/img.chenweiliang.com.conf/usr/local/apache/conf.d/vhosts/img.chenweiliang.com.ssl.conf
- Éditor Konfigurasi WebServers → Setélan WebServer → /etc/nginx/conf.d/vhosts/ → Édit
Lengkah 7: Ganti jalur diréktori folder ngaran domain ieu ▼
/home/用户名/public_html/img.chenweiliang.com
Ganti ku jalur diréktori folder ngaran domain khusus di handap ieu ▼
/home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
Lengkah 8: Pareuman heula layanan httpd ▼
systemctl restart httpd
Lengkah 9: Tambahkeun aturan pangaluaran alihan kana file .htaccess.
Upami anjeun hoyong sacara otomatis ngarahkeun pangguna ka subdomain tanpa domain tingkat luhur www , anjeun kedah nambihan aturan pangalihan kana file .htaccess pikeun ngaluarkeun diréktori folder khusus. ▼
RewriteCond %{REQUEST_URI} !^/img.chenweiliang.com/.*$ [NC]Pasang kodeu ieu sateuacan aturan kahiji pikeun ngahontal fungsi pangaluaran diréktori anu ditangtukeun ▼
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/img.chenweiliang.com/.*$ [NC]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]Lengkah 10: Refresh website pikeun ningali naha parobihan parantos berlaku.
- Tutup CDN subdomain sareng refresh halaman wéb subdomain.
Lengkah 11: Cadangkeun file konfigurasi ka komputer lokal anjeun sareng Google Drive.
- Upami dina Setélan WebServers → Pilih WebServer, saatos nyimpen sareng ngawangun deui konfigurasi, eusi file anu diédit sacara manual di luhur bakal teu valid.
- Éta kedah diédit sacara manual deui, anu nyusahkeun pisan, janten saatos ngedit manual, file kedah dicadangkeun pikeun gancang mulangkeun file konfigurasi anu dicadangkeun.
Di handap ieu paréntah pikeun gancang mulangkeun file konfigurasi vhost cadangan▼
cp -rpf -f /newbackup/backup-vhost-file/nginx-vhosts-file_modified/* /etc/nginx/conf.d/vhosts/ cp -rpf -f /newbackup/backup-vhost-file/apache-vhosts-file_modified/* /usr/local/apache/conf.d/vhosts/
Saatos malikkeun file konfigurasi vhosts cadangan, pastikeun pikeun ngabalikan deui nginx sareng httpd pikeun pangaruh ▼
systemctl restart nginx systemctl restart httpd
- Ieu kanggo tujuan catetan sareng inpormasi wungkul.
Lengkah 12: Anggo plugin Better Search Replace pikeun ngaganti jalurna.
jalur ieu ▼
home/用户名/public_html/img.chenweiliang.com
ganti ku ▼
/home/用户名/public_html/chenweiliang.com/wp-content/img.chenweiliang.com
Lengkah 13: Hapus subdomain gambar ▼
rm -rf /home/用户名/public_html/img.chenweiliang.com
Lengkah 14: Saatos mastikeun sadayana leres, mulangkeun CDN subdomain.
Mudah-mudahan, tulisan "Kumaha Ngaropea Jalur Diréktori Folder Subdomain dina CWP? Ngédit File vhosts" anu dibagikeun dina blog Chen Weiliang ( https://www.chenweiliang.com/ ) tiasa aya mangpaatna pikeun anjeun.
Mangga bagikeun tautan artikel ieu: https://www.chenweiliang.com/cwl-28218.html
