0

In one of my CI application I got a controller called movies in which I am showing details of a movie, its URL looks like

http://localhost/movies/index/12/Movie-Name

here 12 is the movie id which is used for fetching values from db and movie name, which is using for SEO URL.

I would likes to rewrite this URL to

http://localhost/12-Movie-Name

I already removed index.php from my application using http://codeigniter.com/wiki/mod_rewrite

Please help Thanks in advance

2
  • 1
    Do you want the user to access /movies/index/12/Movie-Name or /12-Movie-Name? Commented Jun 11, 2012 at 4:35
  • user access /12-Movie-Name and show the details of movie with primary key 12.. thanks for the reply .. :) Commented Jun 11, 2012 at 4:36

2 Answers 2

1

Maybe try

RewriteRule    ^/([0-9]+)\-([^/]+?)/?$  /movies/index/$1/$2

Although it may cause problems with other parts of your Codeigniter application.

Sign up to request clarification or add additional context in comments.

2 Comments

any solution to avoid problems in other parts ?
I'm not sure, it depends on how you route your application. You should probably check it out, though, just in case.
0

or you can add this to Codeigniter router

$router['/(:any)'] = 'movies/index/12/$1';

but your movies id need to set as string with title.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.