Question: i have a website developed with codeigniter and now i have changed the url structure as below

```
old:
www.website.com/library/country/city/boot_title/book_id

new:
www.website.com/library/bookings/city/country/boot_title/book_id

 www.website.com/library/country/ - displays books country wise
 www.website.com/library/country/city/ - displays books city wise

```

currently there are about 1500 pages with around 100 countries.

what would be the most affective way to redirect or route the old url to the new one?

Answer: 
Maybe this is what you are looking for:

```
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/([\w]+)/([\w]+)/([\w]+)/([\w]+)/([\w]+)/?$
RewriteRule .*   %1/bookings/%3/%2/%4/%5     [L,R=301]

```

Redirects:

`http://www.website.com/library/country/city/boot_title/book_id`

To:

`http:www.website.com/library/bookings/city/country/boot_title/book_id`
You can map old routes to new routes in `application/config/routes.php`.

Check out [this page](http://ellislab.com/codeigniter/user-guide/general/routing.html) of CI docs to see how routes work.

Although you can use .htaccess to rewrite your routes, I think it should be the last resort with any framework that has its own routing as it becomes more difficult to understand/manage and also server specific. Nginx doesn't support .htacess, e.g. Although it might not be a concern until some point.