Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
how to fix URL Resolve, 301 redirects in the htaccess file

I'm a novice and I work PHP. My professor introduced a site that gives me website problems. (woorank) My site has a problem with 301 redirects. Look at the picture below.

Click to see my problem

My problem is and I want to resolve this problem in the .htaccess file. I knew the following code answered this but was wrong

// URL Resolve
if (currentUrl() == "http://example.com") {
    redirectToMainDomain();
} elseif (currentUrl() == "http://www.example.com") {
    redirectToMainDomain();
} elseif (currentUrl() == "https://example.com") {
    redirectToMainDomain();
} elseif (currentUrl() == "https://www.example.com") {
    redirectToMainDomain();
}

I wrote the above code on the first line of codes, but my problem was not resolved, I do something like this to apply in the .htaccess file.

if (currentUrl() == "https://www.example.com" or currentUrl() == "https://example.com" or currentUrl() == "http://example.com" or currentUrl() == "http://www.example.com") {
        header("Location: https://example.com");
        exit;
    }
if (currentUrl() == "https://www.example.com/blog/index.php" or currentUrl() == "https://example.com/blog/index.php" or currentUrl() == "http://example.com/blog/index.php" or currentUrl() == "http://www.example.com/blog/index.php") {
        header("Location: https://example.com/blog/index.php");
        exit;
    } 
// and other pages

Please guide

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

Your site URLs with or without https and www point to different locations that is why your are seeing the redirect error. You can fix this using the following code in your htaccess file:

RewriteEngine on

# rediret http and non-www to https://www
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^ https://www.example.com%{REQUEST_URI} [L,R=301]

Change example.com to your domain in the code above and test it after clearing your browser cache.

over 4 years ago · Santiago Trujillo Denunciar

0

RewriteEngine On
RewriteRule ^(.*)$ http://example2.com/ [R=301]

Add this to the .htaccess which is located in the root folder of your site.

over 4 years ago · Santiago Trujillo Denunciar

0

I am the author of the question. You can fix this using the following code in your .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda