Welcome Guest, Not a member yet? Register   Sign In
remove index from url!
#1

[eluser]Unknown[/eluser]
hello,
i'm trying to make multi pages without index like this
example.com/page/index/sagaw
this is the php i use
Code:
<?php

class Page extends MX_Controller {
public function __construct() {
  parent::__construct();
}
public function index($page = "error") {
  var_dump($page);
}
}
but when i try to open the page like this example.com/page/test it don't work but when i try example.com/page/index/test it work..
#2

[eluser]Punisher[/eluser]
If you want to remove index.php in url you need to setup your .htaccess file. This file should be in your root ci folder.
So your .htaccess file should look like this.

for example where http://localhost/ci_rootfolder/

Code:
RewriteEngine On
RewriteBase /ci_rootfolder/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /ci_rootfolder/index.php/$1 [L]

Remember to replace ci_rootfolder with your ci folder name.

Also you need to setup mod_rewrite if you didn't do so on your server for this to work.

Just to be clear if your ci_rootfolder is in fact your root web folder on server then you can have .htaccess file that looks like this.

for example where http://example.com/

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

#3

[eluser]Unknown[/eluser]
thanks Punisher,
but i've fixed it by adding this line
$route['page/(:any)'] = "page/index/$1";
at routes.php
#4

[eluser]sv3tli0[/eluser]
Using
Code:
$route['page/(:any)']

will kill any posibility to access to any other method in the Page controller!

In your case I can suggest you to name your class different from the required url and then to add custom route.
For example...
Code:
Controller Pages

$route[‘page/(:any)’] = “pages/index/$1”;

and perhaps to use not index method, but perhaps a view...

Code:
$route[‘page/(:any)’] = “pages/view/$1”;




Theme © iAndrew 2016 - Forum software by © MyBB