Reputation: 7338
I get user referrer with r
parameter. (r:code
).
It works well on all :controller/:action/*
pages, but when try to pass it to base path (/), my webserver returns error 403.
Here is my routes.php
file:
Router::connect('/', array('controller' => 'pages', 'action' => 'display', 'home'));
Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connectNamed(array('r' => '[\d]{4}'));
These URLs works well:
http://example.com/pages/home/r:1234
http://example.com/apples/eat/r:1234
but it doesn't work:
http://example.com/r:1234
What's wrong?
Question: Is it the way to capture referrer code from URL? or it's better to use passed arguments? (http://example.com/1234/controller/action/.......
)
Upvotes: 3
Views: 964
Reputation: 66198
If you use a get argument - your code will be a lot more robust:
/?r=urlencodedurl
This is independent of routes and therefore won't break or otherwise be a problem irrespective of the url used. You access get args via the request object:
$r = $this->request->query['r']
Upvotes: 1
Reputation: 2954
Apache 2.2 actually the APR test_safe_name()
function intentionally disallows this kind of
":" character within a URI on Windows servers. because This is basically for avoiding URLs like http://www.mysite.com/C:/SomeFile.exe but is actually annoying.
Also, the Windows FindFirstFile()
function will return ERROR_INVALID_NAME
instead of ERROR_FILE_NOT_FOUND
for any name attempting data stream access using
the ":" character.
The choice of the ":" character as the namespace separator in MediaWiki was an
unfortunate one for use on Windows servers .
Upvotes: 2