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

142
Vistas
Is it possible to configure apache2 to accept query strings appended at the end of a url when separated by the `/` character?

Example... https://myisp.com/mypage.html/foobar I would like to be able to have some js running on mypage.html that can read the foobar as if it were a query parameter. I understand how to write the necessary js, but am trying to understand if Apache can be configured to serve up the html page and pass the final term to a script running on the page.

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

0

There's nothing you can do on the server (ie. Apache) to fool client-side JavaScript in to seeing a "query string" when there is no query string in the visible URL that the browser sees.

Using Apache mod_rewrite you can internally rewrite the request to convert /foobar into a query string - but that's internal to the server. The browser/JavaScript does not see that.

You could implement an external redirect and visibly convert the URL from /mypage.html/foobar to /mypage.html?foobar (or /mypage.html?/foobar) - but I expect that is not what you require.

However, you don't need to convert this to a query string for JavaScript to be able to read it...

/mypage.html/foobar

The part that starts with a slash after a valid filename (eg. /foobar in this example) is called additional pathname information (aka "path-info"). Normally, Apache rejects such requests on the default file handler for text/html files, so the above request would normally result in a 404 Not Found response.

However, you can allow path-info on all URLs by including the following directive at the top of the root .htaccess file:

AcceptPathInfo On

Apache will now serve /mypage.html instead of generating a 404. The browser sees the full URL, ie. /mypage.html/foobar and this is available to JavaScript in the pathname property of the location object (ie. window.location.pathname) which you can then parse to extract /foobar (or foobar).

For example:

// Request "/mypage.html/foobar"
let pathInfo = /\.html\/(.*)/.exec(window.location.pathname)[1];
console.log(pathInfo); // foobar

pathInfo is then your "query string".

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