URL Routing method for core php

2.2k Views Asked by At

I have web site in core php and I want to make my SEF URL. In my web site for transferring control from one page to other i have used something like

    header("Location: edit.php?id=12");

I read one article but couldn't get it how to implement it.

Link of article

So how i can make url to read like "mysite.com/usr/edit" I read lot on google i got the idea that i need to do something in .htaccess but i dont know what needs to do with url in php so i dont have to change major code in site.
Thanks in advance.

1

There are 1 best solutions below

0
On

You can do it with the .htaccess code given below:

RewriteEngine On

DirectoryIndex index.php

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l


RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]

after creating .htaccess file with above code. You will have all the stuff after the file name ex. "/usr/edit" in the GET parameter $GET['url']. After that you can do anything. Here is the working example of my MVC framework: https://bitbucket.org/ManthanB/my-framework/

You can contact me for further information.