How to include a URL in the URL

I have a special controller in my app that is basically an out-gate to capture links leaving the app. A typical URL would look like: /_/out/

I have the route set up properly - I know this because if I go to /_/out/blah-blah-blah, I get the expected output from the controller action.

With this URL though: /_/out/, all I get is the default

The requested URL /_/out/ was not found on this server.

404 error page. It's not the usual one from my app, but just the default Apache error page.

In Volt, I'm generating these URLs with: <a href = "/_/out/{{ url|url_encode }}">. I'm not sure if the problem lies with how I'm encoding the url, or with something in my .htaccess file, which is below:

RewriteEngine On

# Redirect all non-real files to index.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]

Dont ask me why :) but as I experienced before (in Zend Framework 1 too) one (maybe two) more urlencode() calling could solve your problem. see my example:

<a href = "/_/out/{{ url|url_encode|url_encode }}">

$params = $this->dispatcher->getParams();
// it returns

This could help

What I use for uris like these is a safe base64 encode/decode

function base64_url_encode($string) {
    return strtr(base64_encode($string), '+=/', '-~_');

function base64_url_decode($string) {
    return base64_decode(strtr($string, '-~_', '+=/'));

Thanks for the link @stibiumz.

I've actually come to the realization that I don't need to escape anything. I should be able to have my URL look like: /_/out/ The only trouble is in my route, :params will cause the action parameters to be split at each /, rather than leaving it as just one string. So now I think this is a regex problem.

After taking a step back, I realize my approach is completely wrong. Including a URL in my URL won't accomplish what I need anyway, so this i all a moot point. I appreciate the feedback though.