S
S
SimBioT192015-06-11 12:30:29
PHP
SimBioT19, 2015-06-11 12:30:29

Problem with the third CNC parameter, why doesn't it read $_GET?

The problem is this: it doesn't read $_GET['next'] and it's not at all clear why. At first everything seemed to work, but then it broke again. $_GET['next'] is the third parameter, the other two work as they should, but this one resists...
.htaccess looks like this:

RewriteRule ^([-a-zA-Z0-9_]+)/([0-9]+)/([0-9]+)/$ page.php?main=$1&sub=$2&next=$3 [QSA,L]

I have already tried and changed everything, I have looked through about 30 websites, but there is still no answer. Why would it suddenly?
The problem of only the third variable is not limited:
RewriteRule ^([-a-zA-Z0-9_]+)/([0-9]+)/([0-9]+)/([0-9]+)/$ page.php?main=$1&sub=$2&next=$3&last=$4 [QSA,L]

$_GET['last'] will also not be passed

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Vladimir Golubev, 2015-06-11
@SimBioT19

Do you have to accept it as get variables? The easiest way to work with CNC is to create a function or class that will parse REQUEST_URI and return variables.
Something in the style:

function getUriParam($parameterNumber) {
    $arrayParameters = explode('/', $_SERVER['REQUEST_URI']);
    return $arrayParameters[$parameterNumber];
}

You can complicate it, you can make named pairs of parameters, but the simplest implementation is this. Then you just request the desired element (zero will be empty, since the first character in request_uri is a slash, and the first element of the array - everything before the slash - is empty), for example, in the line www.site.ru/pig/dog/cat - getUriParam(2) will return 'dog'.
And you don’t need to go into htaccess - it’s still an external element that depends on the server and not on php, so if you can avoid this dependency, it’s better to do so.

R
Rainbird, 2015-06-11
@Rainberd

line www.site.com/media/1/2 regex^([-a-zA-Z0-9_]+)/([0-9]+)/([0-9]+)/$ does not match the regular expression, you require a slash at the end. request should be www.site.com/media/1/2/

P
Pavel, 2015-06-12
@paveluho

RewriteRule ^([-a-zA-Z0-9_]+)/([0-9]+)/([0-9]+)/([0-9]+)/$page.php?main= $1⊂=$2&next=$3&last=$4 [QSA,L]
this problem is similar to the fact that there is a similar rule before the rule that includes the part of the request with the L flag,
I will clearly give an example:
RewriteRule ^(.*)/( .*)/(.*)/(.*)/$ /?do=open&s=$1&y=$2&x=$3&p=$4 [L] # this is the same rule you wrote
RewriteRule ^(.*)/( .*)/(.*)/$ /?do=open&s=$1&y=$2&p=$3 [L] # this is the rule that "works" before, it should be after
change places and see which ones in the CNC can be similar The URL
may be wrong in this situation without seeing the entire htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question