Digital World Freelancer

The Digital World Freelancer group is applying latest Technologies Like HTML, CSS, CSS3, JavaScript, JQuery, PHP and more...... for website designing & developing... reach at our organization http://www.digitalworldfreelancer.com

Facebook Page

Thursday, October 29, 2015

How to Rewriting URL in Codeigniter from http://www.example.com/users/services/ into http://www.example.com/services

Codeigniter URL Rewriting
mostly we need to rewrite URLs to provide user friendly URLs of projects.
In CodeIgniter its much simple rather than manual writing HTAccess Rules.
Suppose you have :
Controller (users)
Function (index) list of all users
Function (add) add user
Function (view) view user
Function (update) update user information
Function (delete) delete user
Normally URLs will be :
www.example.com/users/index/
www.example.com/users/add/
www.example.com/users/view/
www.example.com/users/update/
www.example.com/users/delete/
But you want that URLs should be:
www.example.com/users/
www.example.com/add-user/
www.example.com/view-user/
www.example.com/update-user/
www.example.com/delete-user/
You do not need to add HTAccess rules in CodeIgnitor.
Just go to /application/config/routes.php
Aprx line 42
add following lines:
$route['users'] = “users/index/”;
$route['add-user'] = “users/add/”;
$route['view-user'] = “users/view/”;
$route['update-user'] = “users/update/”;
$route['delete-user'] = “users/delete/”;
That’s All.
Now you can update your hyperlinks and rewrite rules will be done.
You open path www.example.com/add-user/
it will be opened www.example.com/users/add/

How to redirect from a page into another page when condition is true or false in Codeigniter?

Use the redirect() function from the URL Helper.
EDIT: load the url helper:
Example:-
$this->load->helper('url');
if (condition == TRUE) {
   redirect('new_page');
}
Example:-
Use redirect() helper function.

Example :

$this->load->helper('url');

if ($logged_in == FALSE)
{
     redirect('/login/form/', 'refresh');
}

Contact Page (Form Helper), form Validation and Send Email in Codeigniter

Step:1


Step:2

Step:3

how to rewrite URL From like About_us to about-us this is like - SEO Friendly URLs in Codeigniter

For rewrite URL From like About_us to about-us this is like - SEO Friendly URLs

Step:1:-  Go in your codeigniter project =>   project folder/application/config/routes.php
Step:2:-  $route['translate_uri_dashes'] = False;

so write TRUE in place of False in routes.php here $route['translate_uri_dashes'] = False;

and now refresh your project:

example:- projectname/about_us into projectname/about-us