views:

72

answers:

2

Hi there

I have set up my coldfusion application to have dynamic urls on the page, such as

www.musicExplained/index.cfm/artist/:VariableName

However my variable names will sometimes contain slashes, such as

www.musicExplained/index.cfm/artist/GZA/Genius

This is causing a problem, because my application presumes that the slash in the variable name represents a different section of the website, the artists albums. So the URL will fail.

I am wondering if there is anyway to prevent this from happening? Do I need to use a function that replaces slashes in the variable names with another character?

Thanks

+5  A: 

You need to escape the slashes as %2F.

SLaks
Ok, this seems like an good idea, is there any specif reason to use %2F?
namtax
This is the standard URL encoding.
SLaks
Ok thanks for clarifying
namtax
@namtax, see urlencodedformat() : http://www.cfquickdocs.com/cf9/#urlencodedformat
Henry
thanks henry, that is very useful, never seen that tag before
namtax
+2  A: 

You could easily replace the forward slashes / with something like an underscore _ such as Wikipedia uses for spaces. Replacing special characters with underscores, etc., is common practice.

Caleb Thompson
Thanks for your response, yes i did think that replacing the special characters would be the best idea.
namtax