PHP MVC core implementation tutorial
First of all core mvc works through .htaccess file , The file which is defines url rewriting and get global parameters from Root of server so no need to create index.php file
.htaccess FILE
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourwebsite\.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.yourwebsite.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^yourwebsite\.co.uk$ [NC]
RewriteRule ^(.*)$ http://www.yourwebsite.co.uk/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]
Another Example
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
ErrorDocument 404 "<H1>Page not found</H1>"
you can get "url" variable in any php file
EG.
<?php
echo $_GET['url']; //all parameters values
?>
0 comments:
Post a Comment