Page 1 of 1

Dùng iframe not work erros : in a frame because it set 'X-Frame-Options' to 'sameorigin'.

PostPosted:24 Jul 2018 22:06
by MacKen
CỤ thể mình dùng 2 website wordpress trên 1 vspssim ... có viết 1 file trên web a lấy 10 bài viết mới nhất thử link ok ....

Qua web b dùng iframe link của web a ... kiểm tra web không có dữ liệu views source thầy trong thẻ <body></body> không có dữ liệu trên web b ....
Tìm lỗi thấy thông báo :
Refused to display 'link web a' in a frame because it set 'X-Frame-Options' to 'sameorigin'.


Thử text link web khác ok ....
Có chuyện vpssim bảo mật ko cho web site khác dùng iframe trên vps mình ko ...

Qua trên nhờ nguyễn oanh fix làm sao để web b dùng được iframe web a trên vps của mình..

Xin cảm ơn

Re: Dùng iframe not work erros : in a frame because it set 'X-Frame-Options' to 'sameorigin'.

PostPosted:24 Jul 2018 22:19
by nguyenoanh
Bạn edit vhost của domain đó
Chuyển
Code: Select all
add_header X-Frame-Options SAMEORIGIN;
Thành
Code: Select all
add_header X-Frame-Options ALLOWALL;
Hoặc comment nó luôn là được.

Re: Dùng iframe not work erros : in a frame because it set 'X-Frame-Options' to 'sameorigin'.

PostPosted:24 Jul 2018 22:27
by MacKen
OK rồi ...


Nếu mình muốn chỉ chi phép 1 link http://domain.com/a.php dùng iframe được còn lại không cho phép thì config thế nào nguyễn oanh

Re: Dùng iframe not work erros : in a frame because it set 'X-Frame-Options' to 'sameorigin'.

PostPosted:24 Jul 2018 22:36
by MacKen
ĐÃ tìm ra cách cho file nào cần dùng iframe

Muốn file được website khác dùng iframe thêm dòng

header_remove ("X-Frame-Options");


trên cùng của file sau <?php là ok

Trong file vhost để nguyên dòng add_header X-Frame-Options SAMEORIGIN;

Re: Dùng iframe not work erros : in a frame because it set 'X-Frame-Options' to 'sameorigin'.

PostPosted:24 Jul 2018 22:38
by MacKen
Thử gửi tiêu đề Tùy chọn X-Frame khác, thêm

<?php header('X-Frame-Options: GOFORIT'); ?>
lên đầu trang của bạn. Nó sẽ vô hiệu hóa lệnh SAMEORIGIN.

Re: Dùng iframe not work erros : in a frame because it set 'X-Frame-Options' to 'sameorigin'.

PostPosted:25 Jul 2018 08:01
by nguyenoanh
Đúng là cách edit file php là đơn giản nhất, đỡ phải thay đổi config vhost :)
Tuy nhiên, edit php xong nhớ clear Zend Opcache nhé.