Foros del Web » Programando para Internet » PHP » CodeIgniter »

Remover un dato de la url

Estas en el tema de Remover un dato de la url en el foro de CodeIgniter en Foros del Web. Buenas amigos, esta vez vengo con una pregunta que trata de codeigniter Ya tengo la parte del index.php resuelto (quitarlo del url me refiero) y ...
  #1 (permalink)  
Antiguo 31/10/2011, 18:37
 
Fecha de Ingreso: junio-2009
Ubicación: Madrid
Mensajes: 402
Antigüedad: 14 años, 10 meses
Puntos: 20
Remover un dato de la url

Buenas amigos, esta vez vengo con una pregunta que trata de codeigniter

Ya tengo la parte del index.php resuelto (quitarlo del url me refiero) y me queda la url asi: www.mysite.com/fetch/category/cars he intentado hacerlo con .htaccess pero no lo he conseguido porque por lo visto entra en conflicto con lo de index.php (a lo mejor lo estoy haciendo mal) Alguna sugerencia?

Código:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^localhost$
    RewriteRule . - [E=REWRITEBASE:/codeigniter-mysite/development/]

    RewriteCond %{HTTP_HOST} !^www.mysite.com$
    #RewriteRule . - [E=REWRITEBASE:/]
 
    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    # Enforce www
    # If you have subdomains, you can add them to
    # the list using the "|" (OR) regex operator
    #OPT1:
    #RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
    #RewriteRule ^(.*)$ http://www.plugb.com/$1 [L,R=301]
    #OPT2:
    #   RewriteCond %{HTTPS} !=on
    #   RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    #   RewriteCond %{HTTP_HOST} (.+)$ [NC]
    #   RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

    # Enforce NO www
    #OPT1:
    #RewriteCond %{HTTP_HOST} ^www [NC]
    #RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
    #OPT2:
    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ %{ENV:REWRITEBASE}index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ %{ENV:REWRITEBASE}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 ^(.*)$ %{ENV:REWRITEBASE}index.php?/$1 [L]

    RewriteRule ^(.*)$ %{ENV:REWRITEBASE}fetch?/$1 [L]

</IfModule>
  #2 (permalink)  
Antiguo 31/10/2011, 18:41
Avatar de Ronruby  
Fecha de Ingreso: julio-2008
Ubicación: 18°30'N, 69°59'W
Mensajes: 4.879
Antigüedad: 15 años, 9 meses
Puntos: 416
Respuesta: Remover un dato de la url

Cita:
y me queda la url asi: www.mysite.com/fetch/category/cars he intentado hacerlo con .htaccess pero no lo he conseguido porque por lo visto entra en conflicto con lo de index.php (a lo mejor lo estoy haciendo mal) Alguna sugerencia?
Que es lo que no has conseguido? No entiendo que es lo que quieres remover.
  #3 (permalink)  
Antiguo 01/11/2011, 01:50
 
Fecha de Ingreso: junio-2009
Ubicación: Madrid
Mensajes: 402
Antigüedad: 14 años, 10 meses
Puntos: 20
Respuesta: Remover un dato de la url

Buf, ahora me doy cuenta que se me olvido decir lo que buscaba :) jaja, perdon.

Busco que quitar el fetch de mi enlace. Que quede el plan www.mysite.com/category/cars
  #4 (permalink)  
Antiguo 01/11/2011, 10:57
Avatar de NUCKLEAR
Moderador radioactivo
 
Fecha de Ingreso: octubre-2005
Ubicación: Cordoba-Argentina
Mensajes: 5.688
Antigüedad: 18 años, 6 meses
Puntos: 890
Respuesta: Remover un dato de la url

Cita:
Iniciado por w0rldart Ver Mensaje
Buf, ahora me doy cuenta que se me olvido decir lo que buscaba :) jaja, perdon.

Busco que quitar el fetch de mi enlace. Que quede el plan www.mysite.com/category/cars
Usa routes, es mucho mas "maniobrable"
__________________
Drupal Argentina
  #5 (permalink)  
Antiguo 02/11/2011, 08:38
 
Fecha de Ingreso: junio-2009
Ubicación: Madrid
Mensajes: 402
Antigüedad: 14 años, 10 meses
Puntos: 20
Respuesta: Remover un dato de la url

El problema es que uso una extensión para el tema de multi idiomas.

Este es mi routes:

Código PHP:
$route['default_controller'] = "home";

$route['category/([a-z]+)'] = "fetch/category/$1";
$route['tag/(:any)'] = "fetch/tag/$1";
$route['video/(:num)'] = "fetch/video/$1";

// URI like '/en/about' -> use controller 'about'
$route['^(en|es|ro)/(.+)$'] = "$2";

// '/en', '/de', '/fr' and '/nl' URIs -> use default controller
$route['^(en|es|ro)$'] = $route['default_controller'];
//$route['^(en|es|ro)$'] = $route['category/([a-z]+)']; -> No funcciona

$route['404_override'] = ''
Me anade un en/es o ro antes del controlador es decir que el vinculo quedaría así: www.mysite.com/es/home o www.mysite.com/es/fetch/category/drift . Y entonces, de funciona sin el en/es o ro pero con ello de ninguna manera, y lo necesito para poder cambiar de idioma.
  #6 (permalink)  
Antiguo 07/11/2011, 21:11
 
Fecha de Ingreso: junio-2009
Ubicación: Madrid
Mensajes: 402
Antigüedad: 14 años, 10 meses
Puntos: 20
Respuesta: Remover un dato de la url

Este es mi .htaccess:

Código:
<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteCond %{HTTP_HOST} !^localhost$
    RewriteRule . - [E=REWRITEBASE:/codeigniter-mysite/development/]

    RewriteCond %{HTTP_HOST} !^mysite.com$
    #RewriteRule . - [E=REWRITEBASE:/]
 
    # Removes trailing slashes (prevents SEO duplicate content issues)
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)/$ $1 [L,R=301]

    # Enforce www
    # If you have subdomains, you can add them to
    # the list using the "|" (OR) regex operator
    #OPT1:
    #RewriteCond %{HTTP_HOST} !^(www|subdomain) [NC]
    #RewriteRule ^(.*)$ http://www.plugb.com/$1 [L,R=301]
    #OPT2:
    #   RewriteCond %{HTTPS} !=on
    #   RewriteCond %{HTTP_HOST} !^www\..+$ [NC]
    #   RewriteCond %{HTTP_HOST} (.+)$ [NC]
    #   RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

    # Enforce NO www
    #OPT1:
    #RewriteCond %{HTTP_HOST} ^www [NC]
    #RewriteRule ^(.*)$ http://domain.tld/$1 [L,R=301]
    #OPT2:
    #RewriteCond %{HTTPS} !=on
    #RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
    #RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #'system' can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ %{ENV:REWRITEBASE}index.php?/$1 [L]
    
    #When your application folder isn't in the system folder
    #This snippet prevents user access to the application folder
    #Submitted by: Fabdrol
    #Rename 'application' to your applications folder name.
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ %{ENV:REWRITEBASE}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 ^(.*)$ %{ENV:REWRITEBASE}index.php?/$1 [L]
    #RewriteRule ^(.*)$ %{ENV:REWRITEBASE}fetch?/$1 [L]

</IfModule>
De .htaccess todavia no domino mucho y entonces estos es lo que he ido poniendo junto poco a poco (aunque el fichero .htaccess contiene mucho mas cosas).

Como se dara cuenta esta linea:
Código:
RewriteRule ^(.*)$ %{ENV:REWRITEBASE}index.php?/$1 [L]
me quita el index.php y apartir de esa linea intente esta otra:
Código:
RewriteRule ^(.*)$ %{ENV:REWRITEBASE}fetch?/$1 [L]
Para quitar el /fetch/ pero sin exito.

Algunas otras ideas por favor?

Gracias

Etiquetas: dato, remover, url
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 03:02.