Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!