Languages
[Edit]
EN

Apache 2 - enable encoded slash support in path segments (/ encoding as %2F, e.g. /path/to%2Fendpoint)

7 points
Created by:
Palus-Bear
1016

In this short article, we would like to show how in Apache2 enable encoded slashes support in path segments.

By default, it is not permitted to use %2F in path segments, that causes 404 response in Apache2 server, and it is necessary to enable it.

Apache2 with not permitted %2F in URL.
Apache2 with not permitted %2F in URL.

Quick solution:

Add the following line into your host configuration:

or:

Warning: be careful using %2F in the paths, because some software may do not interpret it well,
e.g. some bots that crawl your website may decode URLs before calling your pages.

 

Available cases

Edit

This section contains description for possible AllowEncodedSlashes values that allows using encoded slashes in URLs.

VirtualHost ConfigurationDescription

In that configuration URLs with %2F are accepted, and encoded slashes are decoded like all other encoded characters.

It means: /path%2Fto%2Fapi will be decoded to /path/to/api and passed to the web application logic.

In that configuration URLs with %2F are accepted, but encoded slashes are not decoded but left in their encoded state.

It means: /path%2Fto%2Fapi will be not decoded but passed to the web application logic with %2F.

Sometimes it is necessary to allow slashes usage with proxy, which can lead to use nocanon parameter in ProxyPass.

Example:

Where: http://127.0.0.1:8080/ receives URLs with %2F codes. 

 

References

Edit
  1. AllowEncodedSlashes - Apache2 Docs
  2. Apache Module mod_proxy - Apache2 Docs

Alternative titles

  1. Apache 2 - allow encoded slash support in path segments
  2. Apache 2 - allow to use %2F in paths
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join