Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
276 views
in Technique[技术] by (71.8m points)

php - Url hide using codeigniter

I am using codeigniter... I want a clean URL from below URL

  http://localhost:8080/rtvnews/index.php/home/videonews?id=67598/newstitle 

here home => controller, videonews => function and ?id=6586565 is a url string.

I want to remove /index.php/home/videonews?id=67598 and replace with /news/

Below Final url I need to get

  http://localhost:8080/rtvnews/news/newstitle 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Follow the steps below

Step 1: .htaccess (the one which is at root folder)

Options All -Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Step 2: routes.php add the code below

$route['rtvnews/news/newstitle'] = 'Your controller/method']; //Just a syntax to change the route in codeigniter. You can change the url as per you want.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...