Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

141
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda