[英]Codeigniter specific URL rewriting
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 在我的一个CI应用程序中,我有一个名为Movies的控制器,其中正在显示电影的详细信息,其URL看起来像
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. 这里的12是电影ID,用于从db和电影名称中获取值,用于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 我已经使用http://codeigniter.com/wiki/mod_rewrite从应用程序中删除了index.php
Please help Thanks in advance 请事先帮助
Maybe try 也许尝试
RewriteRule ^/([0-9]+)\-([^/]+?)/?$ /movies/index/$1/$2
Although it may cause problems with other parts of your Codeigniter application. 尽管这可能会导致Codeigniter应用程序的其他部分出现问题。
or you can add this to Codeigniter router 或者您可以将其添加到Codeigniter路由器
$router['/(:any)'] = 'movies/index/12/$1';
but your movies id need to set as string with title. 但您的电影ID需要设置为带标题的字符串。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.