Are there any downsides to using double-slashes in URLs?

前端 未结 2 1016
情书的邮戳
情书的邮戳 2020-12-16 15:08

I\'ve written my own MVC framework in PHP, which uses urls in the format of:

/controller/method/param1/param2/param...

I\'ve made it so that \"d

2条回答
  •  悲&欢浪女
    2020-12-16 15:41

    Apache treats multiple slashes as a single slash. This affects things such as RewriteRules, e.g. if you have a rule like this:

    RewriteRule ^user/(.*)/([0-9]+)$ /user.php?id=$2 [QSA,L]
    

    That will catch links such as user/nomaD/500 but it will not catch user//500 since it treats that as user/500

    So in other words, I don't think your setup will work since it will treat param1 as method and shift all the parameters left, unless they are of a specific type. I guess this doesn't affect your specific case, but in a lot of situations, this would be a downside to using //.

提交回复
热议问题