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

255
Views
redirigir 301 a / si la URL contiene index.php

Tengo un blog en laravel 5.8 y quiero redirigir 301 a / hay index.php en la url.

Mi .htaccess es este

 <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle www + https RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301] # Redirect if index.php is in the URL RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L] # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule>

He probado este enfoque:

 # Redirect if index.php is in the URL RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]

pero el problema es SI hay una url como esta que contiene (?get_params)

 htts://www.example.com/index.php?test

redirigirá 301 a /?test

¿Cómo puedo cambiar la regla para redirigir 301 a / (sin ningún parámetro?) si la URL contiene index.php ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Puede usar el indicador QSD (descartar cadena de consulta) para redirigir sin pasar la cadena de consulta.

Cuando el URI solicitado contiene una cadena de consulta y el URI de destino no, el comportamiento predeterminado de RewriteRule es copiar esa cadena de consulta en el URI de destino. El uso del indicador [QSD] hace que se descarte la cadena de consulta.

 # Redirect if index.php is in the URL RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC] RewriteRule (.*?)index\.php /$1 [R=301,NE,L,QSD]
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!