Skip to main content
miji.be

X-Frame-Options

An HTTP response header that controls whether a browser should allow a page to be displayed in an iframe.

Sep 5, 2026 / About 1 min read

Security

X-Frame-Options is an HTTP response header that indicates whether a browser should be allowed to render a page in a frame, iframe, embed, or object element. It was introduced as a defense against clickjacking attacks and is supported by all modern browsers.

The header has two directives in current use: DENY (the page cannot be displayed in any frame) and SAMEORIGIN (the page can only be framed by pages from the same origin). A third directive, ALLOW-FROM uri (allow framing by one specified origin), is obsolete; according to the MDN reference (as of July 2026), modern browsers ignore the entire header when they encounter it, so using it silently removes the protection. To allow a specific origin, use the CSP frame-ancestors directive instead. Note also that X-Frame-Options only works as an HTTP response header; setting it in a meta http-equiv tag has no effect.

While X-Frame-Options remains widely used, the frame-ancestors directive in Content Security Policy (CSP) is the modern replacement. CSP's frame-ancestors offers more flexibility, supporting multiple origins and wildcard patterns. When both are present, the CSP specification (Level 2) says frame-ancestors should be enforced and X-Frame-Options ignored. If you set both to cover older environments that do not understand frame-ancestors, keep the two values consistent so that protection holds in environments that read only one of them.

For URL shortening services, setting X-Frame-Options to DENY or SAMEORIGIN on the management dashboard and content pages prevents these pages from being embedded in malicious sites. The redirect endpoints typically do not need frame protection since they immediately redirect rather than displaying content.

Was this article helpful?

Related Terms

Clickjacking

An attack that tricks users into clicking on hidden elements by overlaying transparent frames on top of legitimate web pages.

CSP

Content Security Policy - an HTTP header that controls which resources a browser is allowed to load for a given page.

HTTPS

The secure version of HTTP that encrypts data transmitted between a browser and a web server using TLS.

HTTP Header

Metadata sent alongside HTTP requests and responses. Used for cache control, authentication, specifying redirect destinations, and more.

Referrer-Policy

An HTTP header that controls how much referrer information is included when navigating from one page to another.

Content Security Policy

An HTTP header that restricts the origins from which a web page can load resources. A defense layer that mitigates XSS attacks and data injection.

Related Articles

Short URL Security - Phishing Risks, Safe Sharing Practices, and Protection Guide

A comprehensive guide to short URL security. Understand phishing risks, malware distribution via shortened links, and best practices for safe sharing.

Self-Hosting a URL Shortener: Full Link Control

Explore the benefits and challenges of running your own URL shortening service. Covers open-source tools, serverless architecture, and cost-performance tips.

Click Fraud Prevention: Protect Short URLs from Bots

Understand click fraud tactics and learn how to defend your short URLs. Covers bot detection, rate limiting, CAPTCHA strategies, and anomaly detection.

FAQ

What values can X-Frame-Options be set to?
Two directives are in current use: DENY (blocks all iframe embedding) and SAMEORIGIN (allows embedding only from the same origin). ALLOW-FROM is obsolete, and modern browsers ignore the whole header when it is present, so it should not be used.
What's the difference between X-Frame-Options and CSP frame-ancestors?
frame-ancestors is the successor to X-Frame-Options and offers more flexible control, including the ability to specify multiple origins. When both are set, CSP takes precedence.

Put the terms to work

Shorten a URL for Free