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

119
Views
¿Hay alguna forma de tratar las solicitudes ajax de manera diferente a las solicitudes de los usuarios en .htaccess?

Digamos que tengo /secret/example.php
En mi archivo .htaccess, quiero volver a escribir solicitudes a /secret a /home.html usando

 RewriteRule secret /home.html

Pero ahora, cuando intento acceder a /secret/example.php usando ajax desde example.js

 var xhr = new XMLHttpRequest(); xhr.open('GET', '/secret/example.php', true); xhr.onload = function(){ console.log(xhr.responseText); } xhr.send();

También se redirige y no funciona.

¿Hay alguna manera de que solo pueda reescribir las solicitudes realizadas por el usuario (escribiendo www.example.com/secret en la barra de búsqueda) y aún permitir que ajax acceda al archivo?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Es posible si configura un encabezado adicional en la solicitud xhr: xhr.setRequestHeader("VIAXHR", "true");

Luego en .htaccess algo como esto:

 RewriteCond %{HTTP:VIAXHR} !^true$ RewriteRule secret /home.html
about 4 years ago · Juan Pablo Isaza Report

0

Usar RewriteCond antes de RewriteRule

Documentación de RewriteCond

Algo como esto:

 RewriteCond %{REQUEST_URI} !^/secret/example.php$ RewriteRule secret /home.html
about 4 years ago · Juan Pablo Isaza 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!