How to enable encoded forward slash in path-info in mvc or CodeIgniter app urls

By | May 16, 2023

Path Info Urls

When using path info data , the urls of codeignitor apps or your custom mvc frameworks looks something like this

example.com/index.php/controller/method/param1/param2
or
example.com/controller/method/param1/param2

The path info data can be used to specify which class and method should be invoked on server application.

Forward slash in parameter

Sometimes it might so happen that the pathinfo parameters have a forward slash in them. Such a url when encoded could look like this:

example.com/index.php/controller/method/par%2Fam1/param2

Note that the forward slash is encoded to %2F.

However such urls might not work in the default configuration of Apache and you would simply get a "Page Not Found" error.

This happens if AllowEncodedSlashes directive of Apache is not turned on.
More Here.

This directive should be turned on to allow those sort of Urls. And for codeignitor $config['permitted_uri_chars'] should also be checked to allow forward slash in uri characters.

Links and Resources:

1. Apache Documentation on AllowEncodedSlashes

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

Leave a Reply

Your email address will not be published. Required fields are marked *