2

I want to that when I enter localhost/projectname/index.html it will redirect to

http://localhost/service/welcome/index

For this I write that in .htaccess but it doesn't work

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

Redirect /index.html http://localhost/service/welcome/index

How can I do that?

1 Answer 1

2

In codeigniter there is no files are calling in URL. All what Codeigniter do is use MVC Structure to render view.

As well as if you access anything on root folder(index.html or index.php) it will redirect to application folder. Then default controller is Trigger out.

cz in root there is file call index.php, there you can see

$application_folder = 'application';
$system_path = 'system';

And you can take look at this

  1. routes - config/routes.php
  2. controller - controller/
  3. model - model/
  4. view - view/

and we use .htaccess to remove index.php in URL.

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

if you want to add .html or .php end of URL

in config/config.php

/*

  |--------------------------------------------------------------------------

  | URL suffix

  |--------------------------------------------------------------------------

  |

  | This option allows you to add a suffix to all URLs generated by CodeIgniter.

  | For more information please see the user guide:

  |

  | http://codeigniter.com/user_guide/general/urls.html

 */
$config['url_suffix'] = '';
Sign up to request clarification or add additional context in comments.

8 Comments

There are no redirect options in it?
Then how can I redirect or trigger that?
redirect for what ?? we use .htaccess to remove index.php in URL
I want when I write localhost/projectname/index.html in url it goes to home controller and index action
how it make sure that this url request go to home controller and index action
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.