1
Hello, in my htaccess is like this:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1
RewriteRule ^download/([A-Za-z0-9]+)$ index.php?a=download&k=$1 [QSA,L]
And no download.php
<?php
$k = $_GET['k'];
echo $k;
But it returns this error when I access download/?k=aaaa
or download/?aaaa
Notice: Undefined index: k
index php.
<body>
<?php
require 'config/tratarUrl.php';
include $pag;
?>
</body>
treatUrl.php
<?php
$pUrl = strip_tags(trim(filter_input(INPUT_GET, 'url', FILTER_DEFAULT)));
$sUrl = (empty($pUrl) ? "index" : $pUrl);
$url = array_filter(explode('/', $sUrl));
if (count($url) > 1)
{
$cont = 1;
foreach ($url as $arg)
{
define("PARAM" . $cont, $arg);
$cont++;
}
}
else if (count($url) == 1)
{
if (file_exists(DIR_PAGES . $url[0] . '.php'))
{
$pag = DIR_PAGES . $url[0] . '.php';
}
else
{
if($url[0] != 'index')
{
$pag = DIR_PAGES . '404.php';
}
else
{
$pag = DIR_PAGES . 'home.php';
}
}
} else {
$pag = DIR_PAGES . '404.php';
}
What returns with
var_dump($_SERVER["QUERY_STRING"]);
?– Marcelo de Andrade
Returns
string(13) "url=download/
, Strange he’s not picking up theaaaa
in the end.– Lucas Caresia
I believe your rule should be
RewriteRule ^download/([A-Za-z0-9]+)$ index.php?a=download&k=$1 [QSA,L]
– Papa Charlie
Keeps returning the same error
Undefined index: k
and same messagestring(13) "url=download/"
– Lucas Caresia
I already changed the question.
– Lucas Caresia
Change that line
# RewriteRule ^(.*)$ index.php?url=$1
with the#
at the beginning; this rule is taking everything(.*)
– Papa Charlie