ThaiSEOBoard.com

พัฒนาเว็บไซต์ => CMS & Free Script => ข้อความที่เริ่มโดย: mr.zatan ที่ 01 กุมภาพันธ์ 2020, 15:27:33



หัวข้อ: http to https ยังไงครับ
เริ่มหัวข้อโดย: mr.zatan ที่ 01 กุมภาพันธ์ 2020, 15:27:33
http to https ยังไงครับ


wordpress (nginx + php-fpm)


ไม่ redirect เป็น https ให้ครับ  ไม่รู้จะทำไงดี



หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: iCafe ที่ 01 กุมภาพันธ์ 2020, 15:55:05
add

server {
        server_name domain.com www.domain.com; (http://www.domain.com;)
    listen 80;
    return 301 https://$host$request_uri;
}


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: Mrpoohling ที่ 01 กุมภาพันธ์ 2020, 16:53:37
ลองเพิ่ม code นี้เข้าไปใน .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^โดเมน\.คอม [NC]
RewriteRule ^(.*)$ https://www.โดเมน.คอม/$1 [L,R=301]
</IfModule>

ถ้าไม่ได้ลอง plugin really-simple-ssl ครับ


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: mean ที่ 01 กุมภาพันธ์ 2020, 17:05:01
วิธีตั้งค่า Redirect เว็บไซต์ HTTP:// to HTTPS:// โดยใช้ Code PHP
https://www.ireallyhost.com/kb/ssl/380

วิธีตั้งค่า Redirect เว็บไซต์ HTTP:// to HTTPS:// โดยใช้ .htaccess - ละเอียด
https://www.ireallyhost.com/kb/ssl/379

วิธีการตั้งค่า Wordpress ใช้งาน HTTPS:// , SSL อย่างละเอียด
https://www.ireallyhost.com/kb/ssl/413


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: wiriyaarmz ที่ 01 กุมภาพันธ์ 2020, 17:41:21
ลองเพิ่ม code นี้เข้าไปใน .htaccess

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^โดเมน\.คอม [NC]
RewriteRule ^(.*)$ https://www.โดเมน.คอม/$1 [L,R=301]
</IfModule>

ถ้าไม่ได้ลอง plugin really-simple-ssl ครับ

.htaccess  เป็น config file ของ Apache ครับ เจ้าของโพสบอกไว้ด้านบนว่าใช้ nginx ครับ


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: BrainFreeze ที่ 01 กุมภาพันธ์ 2020, 20:50:38
โค๊ด:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}

ใส่ที่ nginx.conf แล้ว reload สักทีครับ


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: mr.zatan ที่ 02 กุมภาพันธ์ 2020, 06:06:54
โค๊ด:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}

ใส่ที่ nginx.conf แล้ว reload สักทีครับ

เพิ่มทั้งหมดมัย หรือว่าแค่ return 301 https://$host$request_uri; ครับ


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: iCafe ที่ 02 กุมภาพันธ์ 2020, 18:08:32
โค๊ด:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}

ใส่ที่ nginx.conf แล้ว reload สักทีครับ

เพิ่มทั้งหมดมัย หรือว่าแค่ return 301 https://$host$request_uri; ครับ

ทั้งหมดครับ


หัวข้อ: Re: http to https ยังไงครับ
เริ่มหัวข้อโดย: mr.zatan ที่ 03 กุมภาพันธ์ 2020, 09:31:54
nginx.conf
nginx.ssl.conf

Code เดิมที่มีอยู่ตอนนี้

อ้างถึง

server {
    listen      172.0.0.0:80;
    server_name xxxx.com [url=http://www.xxxx.com;]www.xxxx.com;[/url] ([url]http://www.xxxx.com;[/url])
    root        /home/admin/web/xxxx.com/public_html;
    index       index.php index.html index.htm;
    access_log  /var/log/nginx/domains/xxxx.com.log combined;
    access_log  /var/log/nginx/domains/xxxx.com.bytes bytes;
    error_log   /var/log/nginx/domains/xxxx.error.log error;


//เพิ่มแบบนี้เหรอครับ
server {
   listen 80 default_server;
   listen [::]:80 default_server;
   server_name _;
   return 301 https://$host$request_uri;
}

    location / {

        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
            expires     max;
        }

location / {
    try_files $uri $uri/ /index.php?$args;
}

location /ecatalogs/ {
    try_files $uri $uri/ /catalogs/index.php?$args;
}

        location ~ [^/]\.php(/|$) {
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            if (!-f $document_root$fastcgi_script_name) {
                return  404;
            }

            fastcgi_pass    127.0.0.1:9001;
            fastcgi_index   index.php;
            include         /etc/nginx/fastcgi_params;
        }
    }

    error_page  403 /error/404.html;
    error_page  404 /error/404.html;
    error_page  500 502 503 504 /error/50x.html;