But I want urlencode my url because it made the data provided by the user
The solution does not encode the full URL; it encodes only bits that require encoding. Simple coding "the rest" will also fail. For example, in this example, all the dashes ? and = must remain unchanged:
http:
but you need to code the rewritten directory and Hello World, how are you? so that all this forms a valid URL.
As with character encodings, you need to make sure that it is encoded from the very beginning. The solution to your problem (if it exists at all - header() will most likely work without urlencode () in the first place!), Most likely, it will be further in your code.
source share