Skip to content

Did you know?

Apache's Redirect needs a trailing slash: "Redirect / https://example.com" sends /page to https://example.compage.

End the target of Redirect / with a slash: Redirect permanent / https://example.com/

  • Web servers
  • Applies to Apache 2.4
  • Last checked

Explained

Redirect (mod_alias) appends everything after the matched path to the target URL. Match / and leave the slash off the target, and the rest of the path is glued straight onto the hostname:

Redirect permanent / https://example.com    # /blog/post -> https://example.comblog/post
Redirect permanent / https://example.com/   # /blog/post -> https://example.com/blog/post

Apache accepts both lines without a warning, so only a test of a deep URL shows the problem. Redirect keeps the query string either way.

Learn more

← All tech tips · Suggest a fix

Back to top