Hello world..welcome once again to the series of Develop Website using MVC Model Views Controllers.
In this article we'll discuss Creating Routes and Controllers.
In previous article of this series of Develop Website using MVC Model Views Controllers we had discussed directory structure of MVC and we have learned about functions of Models Views and Controllers.
Getting Started,
As you have created directory structure of the MVC in previous tutorial. we continue to implementing on codes of the MVC . before we go for coding we must have proper web access to the MVC. we'll hide all the extensions. on the URL bar so to do that you must create .htaccess file which is read by Web-server and. we write the RewriteEngine to Rewrite URl's we hide .php extensions.
Instead of showing /public/home/home.php we'll show just /public/home/
We can Rewrite URL using .htaccess file to do that create a new file with extension .htaccess itself and put this codes into that and save it on Public folder
Options -MultiViews
RewriteEngine On
RewriteBase /mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
The user should not have to come to our App folder because it's application back-end we can forbid him to come to that location using the same method .htaccess file so to do that create .htaccess file into the App folder and paste this codes into that
This code wont let the users to index the file system if users try to do that it just pops a 403 forbidden access message in web page by default from the web-server. you can Run MVC project at Localhost as well as if you want to create virtual server you are free to do..
In this article we'll discuss Creating Routes and Controllers.
In previous article of this series of Develop Website using MVC Model Views Controllers we had discussed directory structure of MVC and we have learned about functions of Models Views and Controllers.
Getting Started,
As you have created directory structure of the MVC in previous tutorial. we continue to implementing on codes of the MVC . before we go for coding we must have proper web access to the MVC. we'll hide all the extensions. on the URL bar so to do that you must create .htaccess file which is read by Web-server and. we write the RewriteEngine to Rewrite URl's we hide .php extensions.
Instead of showing /public/home/home.php we'll show just /public/home/
We can Rewrite URL using .htaccess file to do that create a new file with extension .htaccess itself and put this codes into that and save it on Public folder
Options -MultiViews
RewriteEngine On
RewriteBase /mvc/public
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
The user should not have to come to our App folder because it's application back-end we can forbid him to come to that location using the same method .htaccess file so to do that create .htaccess file into the App folder and paste this codes into that
This code wont let the users to index the file system if users try to do that it just pops a 403 forbidden access message in web page by default from the web-server. you can Run MVC project at Localhost as well as if you want to create virtual server you are free to do..
No comments:
Post a Comment