I'm generating a download link which I sent through email to download a pdf file. There are some parameters (base64 encoded) in the download link to verify the correct profile/user. I want to be the download link as follows:
www.example.com/download/ZW5jb2RlbXljb2Rl
The parameters are directly added after the subdirectory. I know it can be done with php GET as follows: www.example.com/download/index.php?base64=ZW5jb2RlbXljb2Rl
But in my opinion it is nicer to use the first URL. Except I have no idea how to accomplish this with php. My guess I have to make a rewrite in htaccess?
I found this thread: Rewriting a URL to a PHP parameter from inside a subdirectory
But I already have some htaccess rewrites (JOOMLA), and it is just for the only folder...
Thanks for your effort!
You have no choice but to use rewrite for this That's what it's for.
But I already have some htaccess rewrites (JOOMLA), and it is just for the only folder..
This absolutely does not matter. Your Apache setup can contain as many rewrites as you need. I've seen 100's.
So you could just add these rules above
your current Joomla rules and it should work.
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^download/(.+)/?$ /download/index.php?base64=$1 [L]
Otherwise you would have to do what Jonathan said and use index.php
in your URL.
You can use echo basename($_SERVER['PHP_SELF']);
to see your current page. You can explode the string after the last /
using that:
$filename = explode('/', basename($_SERVER['PHP_SELF']));
That way if your link is www.example.com/download/ZW5jb2RlbXljb2Rl, then filename value will be "ZW5jb2RlbXljb2Rl".
I'm not sure if that's your question, but that should work depending on the usage.