ViewPageSource
Back to Blog
Web Security

X-Frame-Options: Protect Your Site from Clickjacking

Discover how simple HTTP header changes can prevent others from embedding your site in an iframe and protect against clickjacking attacks.

ViewPageSource Team April 7, 2026
X-Frame-Options: Protect Your Site from Clickjacking

![X-Frame-Options Clickjacking Protection](/blog/x-frame-options.svg)

What is Clickjacking?

Clickjacking is a type of malicious attack where an attacker uses an invisible or transparent iframe to trick a user into clicking on a link or button on another website. This can be used to steal sensitive information, perform unauthorized actions, or compromise accounts.

How X-Frame-Options Works

The `X-Frame-Options` HTTP response header allows you to control whether your website can be embedded in an ``, ``, or `` on another domain. By setting this header, you can effectively prevent clickjacking attacks by ensuring that your site is only displayed on your own trusted domain.

Available Directives

1. **DENY**: Prevents any site from framing your content, including your own domain. 2. **SAMEORIGIN**: Allows only sites on the same origin (protocol, domain, and port) to frame your content. 3. **ALLOW-FROM (Deprecated)**: Allows only specific domains to frame your content. This directive is widely deprecated and should be avoided in favor of Content Security Policy's `frame-ancestors`.

Implementing the Header

You can easily implement the `X-Frame-Options` header on your web server or CDN. For example, in Nginx, you would add:

add_header X-Frame-Options "SAMEORIGIN";

In Apache, you would add:

Header always set X-Frame-Options "SAMEORIGIN"

Auditing Your Protection

Use **ViewPageSource** to audit your HTTP headers and ensure that the `X-Frame-Options` header is correctly configured to protect your site against clickjacking.

Conclusion

Preventing clickjacking is an essential part of your website's security strategy. By correctly implementing the `X-Frame-Options` header, you can protect your users and ensure that your content is only viewed on your trusted domain.

HR

About the Creator: Hassan

WordPress Developer | 2 Years Experience

Hassan is the lead developer and visionary behind ViewPageSource. As a Computer Science student and WordPress specialist with 2 years of experience in custom theme and plugin development, he built this tool to bring transparency to the web. Hassan focuses on creating high-performance, developer-centric applications that help others understand and audit the technology stacks behind their favorite websites.

Ready to optimize your site?

Use our professional tools to analyze your source code and technical SEO health in seconds.

Start for Free →