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]

Best Solution

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.

Related Question