Forum Moderators: phranque
RewriteEngine on
RewriteRule \.pdf$ pdf.php [L]
$uri=$_SERVER["REQUEST_URI"];
print("<center><object data='$uri' type=application/pdf width=728px height=90%>");
I suspect that the rewrite engine tries to apply the rule again to the embeded pdf file
RewriteCond %{QUERY_STRING} !.
RewriteCond %{QUERY_STRING} !escape=1 [NC]
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
RewriteRule . index.php [L]
$uri=$_SERVER["REQUEST_URI"];
if (endsWith($uri,".pdf")) {
$out="<center><object data='$uri?escape=1' type=application/pdf width=728px height=90%>";
print($out);
return;
} RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
RewriteRule . index.php [L]
RewriteRule ^filename\.pdf
RewriteCond %{QUERY_STRING} !escape=1 [NC]
RewriteCond %{REQUEST_URI} !\.(gif|jpe?g|png)$ [NC]
RewriteRule . index.php [L]
it does what i want: when I access first my.pdf it goes to index.php
RewriteCond %{QUERY_STRING} !escape=1 [NC]
RewriteRule ^my\.pdf$ index.php [L]
RewriteCond %{QUERY_STRING} !noads=1
RewriteCond %{REQUEST_URI} \.(htm|html|pdf)$
RewriteRule . index.php
$root=$_SERVER["DOCUMENT_ROOT"];
$uri=$_SERVER["REQUEST_URI"];
if ((endsWith($uri,".html") ||endsWith($uri,".htm"))){
$f=$root.$uri;
$c = file_get_contents($f);
$c=addads($c);
print($c);
return;
}
else if (endsWith($uri,".pdf")) {
//embed pdf with noads=1 to skip rewrite rules and avoid infinite loop
$c="<object width=800 height=800 data=$uri?noads=1 type=text/html codetype=application/pdf ></object>";
$c=addads($c);
print($c);
return;
}
function addads($content) { // add banners
return "<table><td>left</td>
<td>top<br>$content<br>bottom</td>
<td>right</td></table>";
}