Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

98
Vistas
How to get entry from MYSQL depending on the entered url?

What I want to achieve is something like Wikipedia is using: You enter "wikipedia.org/wiki/Stack_Overflow" into your browsers search bar and wikipedia shows you the article for "Stack_Overflow". I know I could do something using php's GET and www.website.com/article.html?article_name but I'd like to know how wikipedia's solution works.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You need to rewrite ALL to index.php or router.php.

So in your .htaccess you can try the following:

# Rewrite ALL to index.php
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Then you can handle the request in your index.php file.

You can try somthing like that:

$REQUEST_URI = $_SERVER['REQUEST_URI'] ?? ""; // get the REQUEST_URI
$reqguestedURL = trim($REQUEST_URI, '/'); // remove the leading and trailing '/'
$reqguestedURL = filter_var($reqguestedURL, FILTER_SANITIZE_URL); // sanitize the URL
$URL_array = explode('?', $reqguestedURL); // explode the URL
$destination = $URL_array[0]; // remove the query string
$queryString = $URL_array[1] ?? ""; // get the query string
$destinationParts = explode('/', $destination); // finally get the destination parts.

// so if the URL is: example.com/foo/bar?name=value
var_dump($REQUEST_URI); //OUTPUT: /foo/bar?name=value
var_dump($reqguestedURL); //OUTPUT: foo/bar?name=value
var_dump($URL_array); //OUTPUT: Array ( [0] => foo/bar [1] => name=value )
var_dump($destination); //OUTPUT: foo/bar
var_dump($queryString); //OUTPUT: name=value
var_dump($destinationParts); //OUTPUT: Array ( [0] => foo [1] => bar )

And now you can get the value from your database.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You can do this like WordPress. It means you re-route all http requests in a specific directory to index.php (without redirecting), then you can process what you want by your index.php file.

See WordPress default .htaccess file content here: https://wordpress.stackexchange.com/a/45899

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda