0

Hi all im trying to hide the index.php from the url, well something like that:

i want : mydomain.com/index.php/mycontroler

to be like : mydomain.com/mycontroler

here is my .htaccess

Options -Multiviews
Options +FollowSymLinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]


RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond $1 !^(index\.php|images|robots\.txt|css)

RewriteRule ^(.*)$ index.php?/$1 [L] 

And here is my conf.php

$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

the problem is that it was working good in the local but not in the server

here is the disposition of my files

- bin
- etc
- mail
- public_ftp
- public_html
 -- application
 -- assets
 -- system
 -- .htaccess
 -- index.php

Help guys

4 Answers 4

3
$config['base_url']    = 'http://'.$_SERVER['HTTP_HOST'].'/';
 $config['index_page'] = '';

htaccess:

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

if still getting troubles try changing :

$config['uri_protocol'] = 'REQUEST_URI';
to
$config['uri_protocol'] = 'AUTO';

or somenthing different more (in the config.php you'll find all the options available to try for the uri_protocol param)

Sign up to request clarification or add additional context in comments.

Comments

0

Here is .htaccess stuff,

<IfModule mod_rewrite.c>

    Options +FollowSymLinks -Indexes
    RewriteEngine on

    # NOTICE: If you get a 404 play with combinations of the following commented out lines
    #AllowOverride All
    #RewriteBase /

    # Restrict your site to only one domain
    #RewriteCond %{HTTP_HOST} !^www\.
    #RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d

    <IfModule mod_php5.c>
        RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>

    <IfModule !mod_php5.c>
        RewriteRule ^(.*)$ index.php?/$1 [L]
    </IfModule>

</IfModule>

#prevent access to htaccess file
<Files .htaccess>
 order allow,deny
 deny from all
</Files>

#disable directory browsing
Options All -Indexes
IndexIgnore *

And in config.php

  1. Set base URL like 'http://www.example.com/'
  2. Set $config[‘index_page’] to an empty
  3. string Set $config['uri_protocol'] = 'REQUEST_URI'

3 Comments

@AsmaeDahraoui : Can you mention your version?
its codeigniter 2, and for the server its shared hosting server with php 5.4
try above thing now @AsmaeDahraoui
0

all my .htaccess

RewriteEngine on
RewriteCond $1 !^(index\.php|robots\.txt|static)
RewriteRule ^(.*)$ /index.php/$1 [L]

and you should make sure that property AllowOverride is set correct, eg:AllowOverride ALL in your httpd.conf Directory segment

Comments

0

Make the below changes in the root .htaccess file

 RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

It worked for me.

Comments

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.