URL Routing
URLs in CodeIgniter are intended to be short and internet searcher neighborly. It should sound good to the guests. A client ought to get a thought regarding the page content through its URL.
For instance, http://abc.com/codeigniter/routing_url
The above URL model bodes well and gives a concise plan to the clients what it is about.
One ought to consistently go for the SEO benevolent URL.
URL steering is a procedure through which it changes over SEO cordial URLs into a server code design that comprehends it effectively and drives a solicitation to comparing handler contents.
Setting your own Routing Rules
Steering rules are characterized in routes.php record at the area application/config. In this record you'll see $route cluster, it grants you to indicate your own directing standards. Courses can be ordered in two different ways, either utilizing Wildcards or Regular Expressions.
Wildcards
There are two kinds of special cases:
- :num−series containing just numbers will be coordinated.
- :any−series containing just characters will be coordinated.
Utilizing :num
$route['(blog/:num)'] = 'ladies/social/$1';
URL containing first portion as 'blog' and second section as any 'number' will speak to the URL containing 'ladies' class and 'social' technique going in the match as the variable to the capacity.
It implies when we'll pass URL http://www.abc.com/blog/1
Note: Here, you can pass any number rather than 1 in the URL.
It will be coordinated to http://www.abc.com/ladies/social
Utilizing :any
$route['(blog/:any)'] = 'ladies/social';
URL containing first portion as 'blog' and second section as anything will speak to the URL containing 'ladies' class and 'social' technique.
It implies when we'll pass URL http://www.abc.com/blog/xyz
Note: Here, you can pass anything in the last fragment of URL.
It will be coordinated to http://www.abc.com/ladies/social
Regular Expression
Customary articulations are additionally used to divert courses.
$route['blog'(a-zA-Z0-9]+)'] = 'ladies/social';
You can make your own customary articulation to run your URL.
URL Suffix
To include a postfix in your URL, go to document config.php in application/config envelope and include addition you need as demonstrated as follows. We have included .jsp as the addition.
$config['url_suffix'] = '.jsp';
For instance, if our URL ishttp://www.abc.com/ladies/social
At that point in the wake of including addition, our URL will becomehttp://www.abc.com/ladies/social.jsp