Reescribir la cadena de consulta dinámica

The problem is I have page with player's wallpapers and when user click on a player name, he goes to the page:


I get the name value by $_REQUEST['name'] and I am trying to rewrite:


I have read and tried lot of suggestions on the net with no luck, the best thing I get to in my .htaccess:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond   %{QUERY_STRING} ^name=([-a-zA-Z0-9_+]+)

RewriteRule   ^players/player\.php$ /Football-Players/%1 [L,R=301]

RewriteRule   ^Football-Players/%1 /players/player.php?name=%1 [L] 

But i still get 404 Not found Error.

I test this on wampserver on windows 7

¿Cómo puedo solucionar esto?

preguntado el 09 de septiembre de 13 a las 22:09

2 Respuestas

Habilite mod_rewrite y .htaccess a través de httpd.conf y luego poner este código en su .htaccess bajo DOCUMENT_ROOT directorio:

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+players/player\.php\?name=([^&\s]+) [NC]
RewriteRule ^ /Football-Players/%1? [R=301,L]

RewriteRule ^Football-Players/([^/]+)/?$ /players/player.php?name=$1 [L,QSA,NC]

Respondido el 15 de enero de 14 a las 13:01

Thank you this work for me. I relay cat`t understand every parameter but i will try. Because of my newbie in programing i have in my sql table name parameter with space like "name=Roberto Carlosh". Can i mach spaces in query too? - kokumqvka

Yes space will also be matches since space comes as %20 to Apache. - anubhava

can i replace %20 with "-" for example? - kokumqvka

Can be done but that totally changes the nature of the question. Request you to mark this as accepted and post a new question so that it can be addressed better. - anubhava

In the past you told me this code and how to use it. I just want to ask the meaning of 'Rewritebase /'. On redirecting page, most of elements disappear and i should change the link values for example for css file and more. Can i make it without 'Rewritebase /'? - kokumqvka

Just to confirm have you enabled the rewrite_module in wampserver? You enable it via wampserver -> apache -> modules -> rewrite_module

Respondido el 09 de Septiembre de 13 a las 22:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.