I want to redirect all feed file requests(*.xml) to a php script which will adjust the url of the request and then output the result. I currently have a script which does this, but ends up in an infinite redirect loop. I understand that Apache will request the adjusted file over and over unless I have a condition to stop it, hence I then added a condition to the .htaccess file to only process the file if it originated from root. I thought the concept was good, but still got the same error. The last part of the script is follows: ...
$fileUrl = $row['file_url'] . $feedFile;
}
header('Location: ' . $fileUrl);
header('Content-type: text/xml');
header('Content-length: ' . filesize($fileUrl));
header('Content-Disposition: filename= '.$fileUrl);
header('X-Pad: avoid browser bug');
header('Cache-Control: no-cache');
readfile($fileUrl);
?>
The .htaccess file is as follows: Options +FollowSymlinks
RewriteEngine On
RewriteBase /
#Only process .xml requests if they are from root
RewriteCond %{REQUEST_URI} ^/$
RewriteRule ([a-zA-Z0-9]+\.xml$) checkForAuth.php?file=$1 [QSA]
I get the following error using castfeedvalidator:
Warning: copy( http://www.example.com/SFAPremium.xml?name=ejleeson ) [function.copy]: failed to open stream: Redirection limit reached, aborting in /home/podcasts/public_html/castfeedvalidator/ajax/validate.php on line 243
Thanks, Dion
Your RewriteCond
doesn't look right, try this rule instead:
RewriteEngine On
RewriteBase /
# Only process .xml requests if they are from root
RewriteRule ^([\w-]+)\.xml$ checkForAuth.php?file=$1 [NC,L,QSA]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.