Redirecting all the traffic to index.php with unlimited parameters

  .htaccess, indexing, parameters, php

Let me introduce you to my problem. I am newbie to .htaccess… Untill my .htaccess worked pretty well, here is the code I was using for two url parameters (f.e. www.page.com/en/articles):

# DISABLE CACHING

<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate"
Header set Pragma "no-cache"
Header set Expires 0
Header set Access-Control-Allow-Origin "*"
</IfModule>

Options -Indexes

RewriteEngine on

RewriteCond %{HTTPS} on
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f

RewriteRule ^(.*)$ index.php [R=301,L]

RewriteRule ^([^/]*)(.*)$ index.php?lang=$1&url=$2 [L]

But when I added third parameter like so (f.e. www.page.com/en/articles/20):

...

RewriteRule ^([^/]*)(.*)$ index.php?lang=$1&url=$2&id=$3 [L]

Then echo $_GET[‘lang’] returned "en" (thats OK) BUT echo $_GET[‘url’] returned "/articles/20" and $_GET[‘id’] didnt even exist (Thats NOT OK).

Can anyone please explain to me what in the world am I doing wrong ?

Thanks in advance

Source: Ask PHP

LEAVE A COMMENT