¿Cómo cambiar la URL de la página? [cerrado]

How to get page url and then rename the url based on query result at a time in the address bar ?

sorry for short description..

How can I change page url (working with a exmple.php?id=2 page but the url would be only the name www.something.org/zzz where zzz is the value of name associated with id without any extension that will change based upon query) ?

preguntado el 01 de febrero de 12 a las 14:02

I do hate to say this, but your question raises a whole lot of questions. Could you explain a bit more what you want to do? A URL is something a user sends to a webserver to request something. Do you want to redirect a user after he visited a certain page? -

Véase también so-hints y Cómo preguntar. -

sorry for short description.. How to change page url (working with a exmple.php?id=2 page but the url would be only the name www.something.org/zzz where zzz is the value of name associated with id without any extension that will change based upon query) ? -

3 Respuestas

Look at php docs for $_SERVER['REQUEST_URI'] y header("Location : ").

Respondido 01 Feb 12, 18:02

I'm really not sure what your asking for,

but if you want to get the the URL of the page you are on:

$_SERVER['REQUEST_URI']

Or if your speaking about getting something from the query string you would use:

$_GET['page'] 

Page being the query string of page.php?page=this_page

Respondido 01 Feb 12, 18:02

sorry for short description.. How to change page url (working with a exmple.php?id=2 page but the url would be only the name www.something.org/zzz where zzz is the value of name associated with id without any extension that will change based upon query) ? - Learner Miz

Parece que estás buscando algo como mod_rewrite.

Here is an easier to read explanation: http://corz.org/serv/tricks/htaccess2.php


EDITAR

I think you will need something like this:

ejemplo.php:

<?php
    if (!$_GET["name"] && $_GET["id"])
    {
        // perform MySQL query to get name based on id

        header("Location: http://www.something.org/zzz");
        die();   // stop execution of this page
    }

    // if we got here, $_GET["name"] is set, so do whatever this script is supposed to do.
?>

.htaccess: *see note below

Options +FollowSymLinks
RewriteEngine On

# the following rule will change the URL http://www.something.org/example.php?name=zzz to http://www.something.org/zzz
RewriteRule ^(^example.php?name=(.*)) example.php?name=$1 [NC]

NOTA: The above .htaccess example is NOT tested, and there is a good chance that it doesn't work correctly as it is, but hopefully this helps and you can figure out how to adjust it to do what you want.

Respondido 01 Feb 12, 19:02

sorry for short description.. How to change page url (working with a exmple.php?id=2 page but the url would be only the name www.something.org/zzz where zzz is the value of name associated with id without any extension that will change based upon query) ? - Learner Miz

@Mahfuz: And how will you get the value associated with the id? Via a MySQL query? Do you want the page to actually redirect to that URL, or do you just want the URL in the address bar to change without actually redirecting? - Travesty3

Yes, via mysql query. Actually I want the address bar to change without actually redirecting. - Learner Miz

yes via mysql query and i want it without actually redirecting. - Learner Miz

or redirect while loading . but it will be good if it is possible without redirecting. - Learner Miz

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