php - Url hide using codeigniter -
i using codeigniter... want clean url below url
http://localhost:8080/rtvnews/index.php/home/videonews?id=67598/newstitle
here home => controller, videonews => function , ?id=6586565 url string.
i want remove /index.php/home/videonews?id=67598 , replace /news/
below final url need get
http://localhost:8080/rtvnews/news/newstitle
for hiding index.php url use following htaccess
rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewriterule ^(.*)$ index.php/$1 [l]
considering newstitle unique:
go route.php file (application/config/routes.php) . add new route rule below
$route['rtvnews/news/(:any)'] = 'home/videonews/$1';
in view file
<a href="<?php echo base_url()."rtvnews/new/".$newstitle; ?>" > news title</a>
so url became below
http://localhost:8080/rtvnews/news/uniquenewstitle
your request go home/vidonews function can newstitle parameter.
in controller.php function like
function vidonews($newstitle){}
considering id unique :
add new route rule below
$route['rtvnews/news/(:num)'] = 'home/videonews/$1';
in view.php file
<a href="<?php echo base_url()."rtvnews/new/".$newsid; ?>" > news title</a>
so url became below
http://localhost:8080/rtvnews/news/newsid
now request go home/vidonews function can newsid parameter. in controller.php function like
function vidonews($newsid){}
Comments
Post a Comment