Appache rewrite rules in htaccess file

I am working in a project where we use codeigniter.

If user goto http://www.mysite.com/products.html link then my router look like is

$route['product'] = "product/all_product";

If they click any category say computer the (s)he will redirect to http://www.mysite.com/computer.html and my router is

$route['category/(:any)'] = "product/category_product/$1"; //$1 = computer or electronics

How to do that using .htaccess file?

Answers


@SKG - the url for your codeigniter site will be mysite.com/index.php. You can (and most people do) remove the index.php, so the default url is simply mysite.com

from there, if you have a controller Category with an index($var) function, you can access it via: mysite.com/category/(var)

if you have an existing page at mysite.com/computer.html and you would like it to go to mysite.com/category/(:any) - perhaps because that link is already "out in the wild" in many places and so you want to redirect people to the new url, then you'll want to do the redirect where the computer.html file is and then remap, as shown here:

https://httpd.apache.org/docs/current/rewrite/remapping.html


Need Your Help

search gridview with objectdatasource

asp.net

I have this procedure for performing the search:

Why use javascript callbacks when cleaner syntax is available?

javascript node.js syntax callback code-readability

I'm trying to learn to use Node. So far, so good. But, being pretty new to JavasSript and I don't really get the point of using callbacks when a cleaner and more readable (at least to me) syntax is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.