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

112
Views
.htaccess cómo cargar la página reescrita en lugar de redirigir

Tengo un blog HTML/CSS/PHP puro. La estructura es simple. La página principal es domain.com/blog (últimas publicaciones) y domain.com/blog?page=2 (para publicaciones en la página 2, etc.). Esa página está controlada por el archivo blog.php. Si el usuario quiere leer una publicación, por ejemplo, "Cómo-aprender-pulir", va a domain.com/blog_post?name=How-to-learn-polish y esto también funciona.

Mi problema es cómo escribir una regla en htaccess para cargar el contenido de la página domain.com/blog_post?name=How-to-learn-polish en url domain.com/blog/How-to-learn-polish

Busqué en Internet una solución para mi problema y creé esa regla

 RewriteEngine On RewriteRule ^blog/([^/]*)$ blog_post.php?name=$1 [L,NC]

Esta regla funciona bien en un 80 % porque redirige de domain.com/blog/How-to-learn-polish a domain.com/blog_post?name=How-to-learn-polish

No quiero redirigir pero cargar la publicación en esta URL domain.com/blog/How-to-learn-polish

¿Qué debo cambiar en mi htaccess para hacer eso? Lleno de mi htaccess se ve así

 Header set Cache-Control "max-age=31536000, public" RewriteEngine On RewriteRule ^blog/([^/]*)$ blog_post.php?name=$1 [L,NC] RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301] RewriteBase / RewriteRule ^(.+)\.php$ /$1 [R,L] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ /$1.php [NC,END]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Sus reglas necesitan reordenarse:

 Header set Cache-Control "max-age=31536000, public" RewriteEngine On RewriteCond %{HTTPS} !on RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE] RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)/$ /$1 [L,R=301,NE] RewriteRule ^(.+)\.php$ /$1 [R=301,NC,L] RewriteRule ^blog/([^/]+)/?$ blog_post.php?name=$1 [END,NC,QSA] RewriteCond %{REQUEST_FILENAME}.php -f RewriteRule ^(.*?)/?$ /$1.php [END]

Asegúrese de usar un navegador diferente o elimine los datos de la memoria caché de su navegador para probar esta regla y evitar la memoria caché antigua.

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!