'PHP $_GET[url] not working

HI im trying to develop a MVC pattern through a website , from the beginning I need to get url I tried like this

echo $url= $_GET['url'];
echo $url;

If i use a url like this http://localhost/autolink/index/sdsad it wanna show "index/sdsad" but its not showing anything, what can be wrong on this? can be a version problem? coz used in a another machine it was working..

This is my current .htaccess:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
php


Solution 1:[1]

If that url was working on another machine then you had some sort of rewrite rules in place. You likely had something like:

RewriteEngine On
RewriteRule ^autolink/.* autolink.php/?url=$0 [QSA,PT]

This would make the index/sdsad get passed in as a url argument in the query string.

Your example works for me and implies that you either

  1. Don't have mod_rewrite turned on
  2. Don't have Allow Overrides turned on

Easiest way to check (assuming this is not a production server) is to edit the .htaccess file and put in something like "POOP" on the first line. If you start getting 500 errors, then 1 and 2 above do not apply.

Solution 2:[2]

I develope PHP projects with Visual Studio 2019 Community by using PHP Tools for Visual Studio 2019 and IIS. I got the same problem during testing MVC patern and instead $_GET['url'] which did't work started to use $_SERVER['REQUEST_URI'].

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sharunas Bielskis