Eliminar índice.php Desde URL-Codeigniter 2


Estoy teniendo problemas para eliminar el índice.php desde mis URLs en Codeigniter. He hecho algunos sitios web con Codeigniter 1.7 y el .el código htaccess que utilicé no funciona en 2.

He intentado usar

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

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

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

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

Y

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond $1 !^(index\.php|images|robots\.txt|css)
RewriteRule ^(.*)$ ./index.php/$1 [L]

</IfModule>

También lo he probado sin RewriteBase / in.

He cambiado la conf config['uri_protocol'] a REQUEST_URI y QUERY_STRING y nada.

He establecido $config ['index_page']="";

La estructura del archivo es 192.168.0.130 / (site) / debe estar volviendo a la raíz del servidor y no puede encontrar el índice.archivo php.

Se puede acceder a todos los controladores que he hecho poniendo 192.168.0.130/(site)/index.php/testcontroller

Gracias.

Disculpas si esto se ha preguntado antes - he mirado y probado lo que podía ver.

Editar:

También debo agregar que cambié las carpetas predeterminadas para que sean

Aplicación

CI-2.0

Índice.php

Y cambió las rutas en el índice.php para ser correcto.

Author: Paul, 2011-03-01

7 answers

Pruebe el primer bloque de código que publicó, pero en lugar de /index.php intenta usar/(site) / index.php (obv reemplazando (sitio) con cualquiera que sea el nombre de la carpeta de su sitio).

 22
Author: Jazzerus,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-01 14:54:15

Esto funcionó para mí:

  1. Crea tu archivo htaccess
  2. Establece empty config['index_page'] en un (config vacío.php)
  3. string Set conf config['uri_protocol'] = 'REQUEST_URI'; (config.php)

Este es mi archivo htaccess:

Options -Indexes
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,

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

#When your application folder isn't in the system folder

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

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php

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

# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin   

ErrorDocument 404 /index.php

Fuente:

Http://taggedzi.com/articles/display/codeigniter-2-htaccess-and-friendly-urls

 15
Author: Robin Morgan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-12 12:06:29
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

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

Esto solo se requiere en la carpeta raíz para agregar esto .htaccess

 3
Author: saurabh kamble,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-02-09 00:08:59

Después de seguir todas las instrucciones de otras personas y desde este CodeIgnitor URL documnetation, no olvide reiniciar el servidor. Simplemente olvidé hacer eso y seguí probando todas las demás soluciones.

 2
Author: neelabh,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-03-04 03:54:05

Estuve en esto durante 2 días.. Intenté todo lo posible. Acabo de decir que necesitas lo siguiente:

TIPO:

sudo nano /etc/apache2/sites-available/default

Y cambie AllowOverride None a AllowOverride All - Esto le dará acceso a su .htaccess files

<Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
            # Uncomment this directive is you want to see apache2's
            # default start page (in /apache2-default) when you go to /
            #RedirectMatch ^/$ /apache2-default/
</Directory>

Y también habilita la reescritura de mod en Apache:

http://stackoverflow.com/questions/3131236/how-do-you-enable-mod-rewrite

Espero que esto ayude, Mário

 2
Author: Mário Carvalho,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-10-10 11:35:02

Solo necesita agregar el código a continuación .htacess.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
 1
Author: daxter,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-05-05 13:48:55

1) Crear .archivo htaccess en su carpeta raíz

 RewriteEngine on
    RewriteCond $1 !^(index\.php|resources|robots\.txt)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]

2) Editar application / config / config.archivo php en la carpeta de la aplicación

$config['base_url'] = 'http://localhost/projectName';

 $config['index_page'] = '';         // remove index.php 

Espero que funcione para usted

 1
Author: tushar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-14 14:07:59