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

213
Views
Apache - RewriteCond/RewriteRule for URL in HTTPS and with a specific parameter

I need to add a parameter to the URL if the URL is being accessed in https and only if the parameter doesnt already exists (I don't need to check the parameter value).

  1. Example 1: nothing should be done because the url is being accessed in http

    Original URL: http://example.com
    Final URL: http://example.com

  2. Example 2: Apache needs to redirect to https://example.com?parameterName=parameterValue

    Original URL: https://example.com
    Final URL: https://example.com?parameterName=parameterValue

  3. Example 3: Nothing should be done because the url is in https and contains the parameter "parameterName" (this one is to prevent infinite loop)

    Original URL: https://example.com?parameterName=parameterValue
    Final URL: https://example.com?parameterName=parameterValue

What I've tried so far :

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !^parameterName$ [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}%parameterName=parameterValue

Edit 1: If I remove the "RewriteCond %{HTTPS} on" condition it seems the rule is being executed. The parameters are not being appended correctly but at least the rule is being executed.

Now I need to understand why the rule is not being executed when in HTTPS.

Googling a bit I found some posts saying that the AllowOverride has to be changed to AllowOverride All.

I updated the line below in my httpd-conf file but the behaviour did not change:

From: AllowOverride None
To to AllowOverride All

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The code below did what I needed:

RewriteCond %{HTTPS} on
RewriteCond %{QUERY_STRING} !.*parameterName.*
RewriteRule /myapplicationpath?(.*) /myapplicationpath?parameterName=parameterValue&%{QUERY_STRING} [R]
over 4 years ago · Santiago Trujillo 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!