In .htaccess leave requested path in %{REQUEST_URI}

Created on 2 November 2020, over 4 years ago
Updated 7 January 2025, 4 months ago

Problem/Motivation

Currently in .htaccess, the index.php rewrite is:

    RewriteRule ^ index.php [L]

This rewrite has worked well, but with one issue. It changes the %{REQUEST_URI} variable to "index.php", making it subsequently impossible to use Apache directives that rely on the %{REQUEST_URI} variable, either in the core httpd configuration or later in the .htaccess file.

Steps to reproduce

For example, the following directive would fail to set the WIDGET variable to true if if a request was made for "/widget":

    RewriteCond %{REQUEST_URI} (/widget)
    RewriteRule ^ - [ENV=WIDGET:true]

Proposed resolution

The proposed resolution is to change the index.php rewrite directive to be:

    RewriteRule ^(.*)$ index.php/$1 [L]

This leaves the requested path in %{REQUEST_URI}, where it can be used in subsequent directives.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

base system

Created by

πŸ‡ΊπŸ‡ΈUnited States mikegodin

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024