JustUser
JustUser

Reputation: 118

How to remove Controller and method name from URL in CodeIgniter

Currently my URLs look like this

http://www.domain12.co.un/register/user/A123

I want to remove /register/user/ from URL So, It should look something like this.

http://www.domain12.co.un/A123

Parameter A123 is not constant in above URL, It may change B123, G123, 3FG567... etc.

I gone through this but getting 404 error. I have added below code in my routes.php but it's not redirecting to other page.

 $route['(:any)'] = "register/user/$1";

Upvotes: 0

Views: 628

Answers (1)

Akshit Ahuja
Akshit Ahuja

Reputation: 337

Do one more thing..

Create .htaccess file and paste the below code

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule>

and save this .htaccess file in your root folder and then try

Upvotes: 1

Related Questions