2

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]
1

2 Answers 2

4

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.

Sign up to request clarification or add additional context in comments.

5 Comments

I added your comment to your original question.
'RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]'
Im not geting any 500 error, rest of the things on that page working perfectly. only echo $url= $_GET['url']; not showing
Thank you very much its working now... I didnt do anything.. the problem on Browser. Thanks ALOT sberry
Now I can get url from echo $url= $_GET['url']; but when I use localhost/autolink/index/sdsad index is not showing let say if i use othe than index then its working , localhost/autolink/notindex/sdsad .. why is that?
0

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'].

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.