Reputation: 10105
I have below Url in my sample application in PHP MVC CI
http://localhost:1234/Sample/Index.php/User/index
Here User is Controller
and index is Action Method
Can I write this url like below ?
http://localhost:1234/Users
Upvotes: 1
Views: 125
Reputation:
If you would like to use custom routes. http://www.codeigniter.com/user_guide/general/routing.html
You do not need to include index.php in routes.php
// application > controllers > sample > Users.php filename first letter must be uppercase. Same with class name.
$routes['users'] = 'sample/users/index'; // Lower case preferred.
// When with out function would go straight to index function
$routes['users'] = 'sample/users';
// No Need for index.php
// $routes['Users'] = 'Sample/Index.php/User/index';
Now url will be
http://localhost:1234/project/users
http://localhost/project/users
Or with index.php
http://localhost:1234/project/index.php/users
http://localhost/project/index.php/users
You may need to remove index.php here are some htaccess
https://github.com/riwakawebsitedesigns/htaccess_for_codeigniter
application > config > config.php
$config['index_page'] = '';
htaccess example
Options +FollowSymLinks
Options -Indexes
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]
If your using WAMP make sure you have rewrite module enabled.
Upvotes: 0
Reputation: 11987
After seeing your code , main mistake you have done you have renamed index.php
, which is wrong, please revert that index1212.php
to index.php
Rest of the thing you can follow other answers.But this is maon, codeigniter will not run without index.php
file
Edit
One more error i noticed, in routes.php
,
its
$route['Users'] = 'user/';
not $routes
And access your project like this,http://localhost/Sample/Users
And as far as my knowledge, you cannot hide folder name in url.
Upvotes: 2
Reputation: 3437
Sample
is your project dir so you can not write the route which you want you can write the route as bellow.
And your route file will look like bellow.
$route['Users'] = 'User/index';
Upvotes: -1