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

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

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 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