我想创建一个用于添加书签的书签。因此,您只需点击书签中的Bookmark this Page
JavaScript代码段,即可将其重定向到页面。如何将URL编码为CakePHP参数
这是我目前的书签:
"javascript: location.href='http://…/bookmarks/add/'+encodeURIComponent(document.URL);"
这给了我这样一个URL,当我点击它的书签页:
http://localhost/~mu/cakemarks/bookmarks/add/http%3A%2F%2Flocalhost%2F~mu%2Fcakemarks%2Fpages%2Fbookmarklet
服务器不喜欢,虽然:
The requested URL /~mu/cakemarks/bookmarks/add/http://localhost/~mu/cakemarks/pages/bookmarklet was not found on this server.
这给了想要的结果,但没什么用了我的使用情况:
http://localhost/~mu/cakemarks/bookmarks/add/test-string
有正在进行CakePHP的典型mod_rewrite的,它应该最后一部分转变成一个参数为我BookmarksController::add($url = null)
行动。
我在做什么错?
这工作。但是如果你不用任何东西来替换,'='会发生什么。不需要吗? –
它不适用于IE8。 –
'='是填充,并非严格需要。请查看[此处](http://en.wikipedia.org/wiki/Base64#Padding)以获取有关填充的说明。 PHP可以解码Base64而无需填充。 – poplitea