Signature
Parameters
This function takes no parameters.Return Value
The URL-encoded path of the current request (e.g.,
/my%20page.sql)Description
Thepath() function returns the path portion of the current request URL. This is useful for:
- Generating links to the current page
- Handling proxy URL rewrites
- Building navigation based on the current location
- Creating self-referencing forms
%20, etc.
Examples
Self-Referencing Form
Create a form that submits to the current page:Highlight Current Page in Navigation
Build a navigation menu that highlights the current page:Filter by Page Section
Use path to show different content based on the current page:Breadcrumb Navigation
Generate breadcrumbs based on the current path:Preserve Current Page in Links
Create links that modify parameters while staying on the same page:Working with Proxies
When behind a reverse proxy that rewrites URLs:Path Format
- Starts with
/ - URL-encoded (spaces =
%20, etc.) - Includes file extension (
.sql) - Does NOT include query string (use
sqlpage.variables('get')for parameters) - Does NOT include hash/fragment
Example Paths
| URL | sqlpage.path() |
|---|---|
http://example.com/page.sql | /page.sql |
http://example.com/my page.sql | /my%20page.sql |
http://example.com/admin/users.sql?id=5 | /admin/users.sql |
http://example.com/ | /index.sql |
Related Functions
- sqlpage.link() - Build URLs with parameters
- sqlpage.set_variable() - Create URLs with modified parameters
- sqlpage.variables() - Access URL parameters
- sqlpage.request_method() - Get HTTP method