View Full Version : Setup For .html/.htm Files Without A Footer File
digitalpoint
Dec 1st 2004, 9:06 am
Here's a quick little setup if you have a site where the server supports mod_rewrite and PHP, but all your files are .htm or .html...
All these files would go in the root folder of your site:
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
passthru.php
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
Drop the normal ad_network.php and empty ad_network_ads.txt file into the folder as well.
What it will do is read any .htm or .html file, and insert the ad before the </body> tag. You can change it up to adjust formatting or for multiple ads, but it should be a start for those that need it.
rustybrick
Dec 1st 2004, 9:07 am
Isnt he just great?
chachi
Dec 1st 2004, 9:09 am
wonder if the guy ever sleeps
Stretch
Dec 1st 2004, 9:18 am
Thanks Shawn
What's the advantage of using passthru.php instead of having:
AddType application/x-httpd-php .php .htm .html
in your .htacess and including the code as per usual?
digitalpoint
Dec 1st 2004, 9:25 am
The only real advantage is you don't have to add the PHP code to all the files.
Stretch
Dec 1st 2004, 9:29 am
Oh, I get it now. Very cool. Thanks again.
seohome
Dec 1st 2004, 11:02 pm
Hi Shawn,
Two problems:
How do I add it to the main page? For some reason (I'm guessing because it doesn't end in .htm) the ads don't appear in there.
How do I add multiple ads? I can only add one...
Thanks
schlottke
Dec 1st 2004, 11:08 pm
seohome, you add that code into the .htaccess file.
seohome
Dec 1st 2004, 11:12 pm
seohome, you add that code into the .htaccess file.
.... which code?
Sorry, not an expert programmer
schlottke
Dec 2nd 2004, 1:24 am
The top code, the one below .htaccess in bold.
zamolxes
Dec 2nd 2004, 3:26 am
I've tried adding the code to the .htaccess file but that causes an internal server configuration error. I tried it on 2 servers - no success.
digitalpoint
Dec 2nd 2004, 7:07 am
You server may not allow mod_rewrites... if you check your error log, you will know for sure.
seohome
Dec 2nd 2004, 9:01 am
The top code, the one below .htaccess in bold.
I added that code. I mean, the script IS working for me. It just doesn't appear in the index...
Also, I don't know how to add multiple ads with this system (the code is too messy for me to handle it :confused: )...
Thanks again for the help
digitalpoint
Dec 2nd 2004, 9:15 am
Is your index a .html or .htm file?
For two ads (as an example) you could add:
. ' - ' . $ad_network[1]right after the $ad_network[0] variable. That will put a dash between them.
seohome
Dec 2nd 2004, 9:24 am
My index is a .htm and so are all my other pages but the ads don't appear in the index :confused:
I tried to add that code to have multiple ads (exactly the same) but I didn't succeed. I guess it is because I have to write an include for each ad_network... but where do I add it?
Thanks Shawn
digitalpoint
Dec 2nd 2004, 9:50 am
What's your site URL?
You don't need multiple includes if you have the latest ad_network.php file (from yesterday or today).
seohome
Dec 2nd 2004, 9:58 am
My URL is http://www.poems-and-poetry.com
By the way, I've added the multiple ads thanks to the new ad_network.php :)
Edit: I made the code to replace "SEO Firm: SEOHome" by the way.
digitalpoint
Dec 2nd 2004, 10:06 am
Not sure to be honest... They are there if you specifically specify index.htm I also tested it on this end, without the filename being specifically specified and it's working for me. So the only thing I can think of is maybe Apache isn't seeing the actual filename somehow with the %{REQUEST_FILENAME} variable.
seohome
Dec 2nd 2004, 10:11 am
Yeah... I tried to add some more conditions to the .htaccess regarding the domain but couldn't do it.
The only way I got the ads to appear is by placing AddType application/x-httpd-php .php .htm .html in the .htaccess above <IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule> and the other code directly in the index. However, when I did this, the ads stopped appearing in the internal pages :rolleyes:
digitalpoint
Dec 2nd 2004, 10:19 am
You could do it with the rewrite, then change your index.htm to index.php I suppose... unless you are linking specifically to index.htm somewhere.
seohome
Dec 2nd 2004, 10:20 am
The .htaccess is bringing me troubles with my php pages so I I'll have to remove the whole code :(
digitalpoint
Dec 2nd 2004, 10:21 am
No, the original .htaccess file (check the beginning of this thread).
ericn
Dec 2nd 2004, 6:51 pm
I finally got this working. Now I just need to figure out how to have five adds going?
How would this be done?
digitalpoint
Dec 2nd 2004, 7:41 pm
There are instructions in this thread.
ericn
Dec 2nd 2004, 8:15 pm
Please excuse my lack of scripting.
I have read the entire thread twise. I do not see how to edit this .html method to show the add five times.
digitalpoint
Dec 2nd 2004, 8:17 pm
Check post #14.
zamolxes
Dec 3rd 2004, 12:30 am
I'm getting a configuration error when trying to add the code to the .htaccess file:
It's this line that seems to cause it:
RewriteRule ^(.*) /passthru.php?file=$1
digitalpoint
Dec 3rd 2004, 12:44 am
Check your httpd error log. Your server might not allow it.
Spyware Remover
Dec 3rd 2004, 4:02 am
When I added the mod rewrite code to my .htaccess file, I got server 500 erros on my site. (html based)
I have tried getting the ad network on my site many times to no avail. No matter what I do I can never get validation or the ads to display.
I usually have no problem with things like this, but this one stumps me completely.
I am hosted on iPowerWeb, they want me to do things differently with the .htaccess like:
AddType text/x-server-parsed-html .shtm .shtml .htm .html
for SSI.
I am stumped
AJ
zamolxes
Dec 3rd 2004, 5:06 am
I am already using mod_rewrites on one of the sites is just this one that doesn't want to work - results in server configuration error.
I have tried this already on 4 different servers now - I must be doing sth. wrong :( .
The error log shows:
File does not exist: ...../public_html/404.shtml
File does not exist: .../favicon.ico
Foxy
Dec 6th 2004, 9:11 am
Hi Shawn, I tried this on world-ok.com and got the internal server error - so I rechecked that the engine was on which it is and then today I refed the htaccess and the same error occurred - I have a few "old" sites, with many pages that I would like to use this on so it is worth continuing - any ideas?
Thanks :)
digitalpoint
Dec 6th 2004, 9:26 am
Most likely your server configuration doesn't allow the mod_rewrite. If you have access to check the httpd error log, you might want to check it.
Foxy
Dec 6th 2004, 10:04 am
I checked the error log before I asked the techies and there was no error logged - I shall go back and ask more specifically
Thanks
Patient
Dec 6th 2004, 10:15 am
Hi Foxy
I have a few sites where I have been able to use a .htaccess file to get htm processed as php using:
AddType x-mapp-php4 .php3 .php .html .htm
This is hosted by 1&1 so the settings are probably atypical.
Not as neat as Shawns as you still need to add the code to every page. More hosts seem to support this though.
digitalpoint
Dec 6th 2004, 10:15 am
You sure you are looking in the right error log? Usually it's named error in /var/log/httpd
Foxy
Dec 6th 2004, 11:56 pm
Unfortunately for me I have tried it on two different ISPs with the same result - one in Florida with cpanel and the other in California with vdeck - so I guess its a no go for me.
Thanks anyway Shawn :)
OnSEO
Dec 7th 2004, 2:10 am
After fooling around with this for 2 days..I still cant get it to work..I contacted mt host, and they confirmed that that the rewrite is enabled.
Any ideas?
Spyware Remover
Dec 7th 2004, 3:07 am
Yeah, I am in same boat. It's hopeless. I have tried four different configurations with the htaccess file and then the mod re-write and it's still a no go.
I am hosted on iPowerWeb, which isa major company and no one (here) has been able to shed any light on the subject in order for me to getthis network up and running.
AJ
digitalpoint
Dec 7th 2004, 7:55 am
Often there are different levels of a rewrite available (some hosts allow some things but not others for example). The only way to find out for certain what the error you get would be to check /var/log/httpd/error (your administrator will probably need to do it for you).
Bulldog San
Dec 7th 2004, 9:43 pm
I've successfully gotten the ads running on my site. Thanks for the html version. How do I change the font and size of the ads if I don't have a footer file?
OnSEO
Dec 7th 2004, 9:45 pm
Glad you could...I couldn't
Bulldog San
Dec 7th 2004, 9:49 pm
I'm a complete newbie. Built my first site in October - didn't even know what a footer file was until today. I'm using Dreamhost - it's not a problem there.
Bulldog San
Dec 7th 2004, 9:51 pm
Oh, here's the instructions I got...
1. Place this code in your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
2. Create a new file in the root folder titled "passthru.php" and insert this code:
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
3. Create a new file in the root folder titled "ad_network.php" and insert this code:
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
if (!function_exists('make_seed')) {
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand (make_seed());
}
if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;
$ad_file = 'ad_network_ads.txt';
for ($i = 0; $i <= 11; $i++) {
$p = substr ('../../../../../../../../../../', 0, $i * 3);
if (file_exists ($p . $ad_file)) {
$ad_file = $p . $ad_file;
break;
}
}
if (is_writable ($ad_file)) {
$ads = file_get_contents ($ad_file);
$ads = explode ('<ad_break>', $ads);
if (count ($ads) < 401 || $ads[0] + 900 < time()) {
$new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?s=' . $_SERVER['SERVER_NAME'] . '&type=link');
$ads[] = $new_ad;
$ads[0] = time();
if (count ($ads) > 401) unset ($ads[1]);
if ($new_ad) {
$file = fopen($ad_file, 'w');
fwrite ($file, implode ('<ad_break>', $ads));
fclose ($file);
}
$ad = end ($ads);
} else {
$ad = $ads[rand(1,count($ads) - 1)];
}
$ad_network[] = $ad;
while (count ($ad_network) < 5) {
$ad_network[] = $ads[rand(1,count($ads) - 1)];
}
} else {
$ad_network[] = 'You must set the "ad_network_ads.txt" file to be writable.';
}
if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
ini_set ('zlib.output_compression', 0);
echo end ($ad_network);
}
?>
4. Create a new file in the root folder titled "ad_network_ads.txt" and leave it empty. Also change the file permissions to 777.
ResaleBroker
Dec 8th 2004, 12:18 pm
We have helped someone get the Ad Network running on their HTML site and everything is running great.
We would like to format the text to match their font.
I'm assuming this would be done in the passthru.php file. Can anyone provide an example?
digitalpoint
Dec 8th 2004, 12:23 pm
You would want to surround the ads with <span> or <div> tags and do it with CSS.
ResaleBroker
Dec 8th 2004, 12:27 pm
Like this?
<div class="menu">
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
</div>
seohome
Dec 8th 2004, 12:42 pm
Well, I just finished uploading the working version. This site gave me the 500 error (as some of yours) and I simply added the code 1 by 1. That way, it didn't return any errors. You have to upload all your files but it's not that bad. I hope you can make it work too :) .
digitalpoint
Dec 8th 2004, 1:03 pm
On the passthru.php method, you would want to add it before and after the $ad_network[0] in the preg_replace function.
ResaleBroker
Dec 8th 2004, 1:17 pm
Thanks Shawn!
Hank
Dec 9th 2004, 4:25 pm
Bulldog San or Shawn:
For the above listed .htaccess and other files (for .htm or .html use in the ad network), what code(s) exactly needs to go into the actual .htm files?
I've got the files created and uploaded to my site, but cannot quite figure out what code to put into the actual website pages.
My site is http://www.everensec.com/
So as you can see, this is currently a small 4 page straight html site. The site is on a Linux / Apache shared server where php etal are supported.
Thanks for any help!
Hank
digitalpoint
Dec 9th 2004, 4:41 pm
Nothing needs to go in your html files.
Bulldog San
Dec 10th 2004, 9:13 am
Magically, it puts the text links just before the </body> tag. Don't ask me how.
Hank
Dec 10th 2004, 9:56 am
Thanks Shawn.
I've had several go arounds with my host and their techies. I happen to have a very good relationship with them.
Anyway, I'm still not having any luck. The mod_rewrite is enabled. I'm getting this error:
--
[Fri Dec 10 10:19:33 2004] [error] [client 202.88.230.11] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
[Fri Dec 10 10:19:33 2004] [error] [client 202.88.230.11] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
--
then, my engineer said this:
It is very clear the reason of that error from the error logs itself. The redirect rules specified in .htaccess file were the following:
--
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
--
Among those rules, the rewritecond REQUEST_FILENAME doesn't exist (or an invalid condition) and it triggers only the RewriteRule, ie without checking any prior conditions. And it was falling in an infinite loop, giving those errors.
---
All my files are .html extensions.
The engineer has suggested to replace REQUEST_FILENAME with SCRIPT_NAME, which we did as a test. That ceased the 500 server error, but there are still no ads on my site.
:confused:
Also, I've put the two php files and the .txt file in both my WWW and my root directories to do some tests. I still get 500 errors when those files are in the WWW directory (the .txt with 777 chmod) and the specified .htaccess proper code from Shawn.
Any ideas or suggestions?
I'd love to get this going. Have over a dozen sites, most using .html files. This is killing me!
Hank
Hank
Dec 10th 2004, 2:47 pm
I couldn't get the .htm / .html workaround to function properly.
So I renamed my files to .shtml, renamed the internal links to .shtml for all visible files, put the specified files and additions together and IT WORKS!
Yehaw! :D
So I go log into the coop network section to validate the site, and the tool tells me a bunch of .html pages aren't valid. I delete those pages, as I no longer need them anyway.
The odd thing is none of those pages are linked anywhere on the live site.
Shawn, now that I have deleted them, your tool is still saying they are in the directory and they are "not valid". I cannot see the deleted files in my FTP client, nor in the File Manager of Cpanel (the site control panel).
Any suggestions?
Also, I have some optin email confirmation pages that I've left as .html files. Will your tool find those and prevent activation?
For some reason I just figured the validation tool would seek live and linked pages.
Thanks for any tips.
Hank
Foxy
Dec 10th 2004, 11:54 pm
I couldn't get the .htm / .html workaround to function properly.
So I renamed my files to .shtml, renamed the internal links to .shtml for all visible files, put the specified files and additions together and IT WORKS!
Yehaw! :D
So I go log into the coop network section to validate the site, and the tool tells me a bunch of .html pages aren't valid. I delete those pages, as I no longer need them anyway.
The odd thing is none of those pages are linked anywhere on the live site.
Shawn, now that I have deleted them, your tool is still saying they are in the directory and they are "not valid". I cannot see the deleted files in my FTP client, nor in the File Manager of Cpanel (the site control panel).
Any suggestions?
Also, I have some optin email confirmation pages that I've left as .html files. Will your tool find those and prevent activation?
For some reason I just figured the validation tool would seek live and linked pages.
Thanks for any tips.
Hank
You will always find this problem Hank until Google 'sees' that the pages have gone - remember it uses the API to get all of its information.
Generally speaking though it only picks up the more relevant files [which is obvious as a page you forgot somewhere deep could kick out the system and yet its chance of being seen is very small] so when it does kick you out it reports the page - go fix the page and revalidate. :)
Hank
Dec 13th 2004, 1:44 pm
Shawn:
For my 4 page site, I was able to rename the pages to .php and move them to a new domain and the tool validated it.
However, I've got several sites well over 100 .html pages, and I'd really like to get in and contribute to this network and receive a little too.
So today I'm back to trying the different methods and still generating 500 server errors.
In a previous post, you asked another person to post their error log.
I'm getting this error:
mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
I'm using a shared host who uses Linux / Cpanel. I've got two entirely different sites on two different hosts, and no matter what I try when using the .htaccess / passthru.php method, I still get the error above.
Do you think the host doesn't have the mod_rewrite set to proper levels?
Thanks for any suggestions.
Hank
ResaleBroker
Dec 13th 2004, 7:12 pm
On the passthru.php method, you would want to add it before and after the $ad_network[0] in the preg_replace function.I'm having trouble with formatting with the passthru.php method. Can anyone give an example with the code below of where the formatting should be placed?
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network[0]. ' - ' . $ad_network[1]. ' - ' . $ad_network[2] . ' - ' . $ad_network[3] . ' - ' . $ad_network[4] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
digitalpoint
Dec 13th 2004, 7:15 pm
Like this:
echo preg_replace ("/<\/body>/i", '<div class="menu">' . $ad_network[0]. ' - ' . $ad_network[1]. ' - ' . $ad_network[2] . ' - ' . $ad_network[3] . ' - ' . $ad_network[4] . '</div></body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
ResaleBroker
Dec 13th 2004, 8:22 pm
Thanks Shawn!:)
g00gl3r
Dec 14th 2004, 6:56 am
I'm using a server using HELM and can't get it to run as standard or with this helpful mod... Help? more details: http://forums.digitalpoint.com/showthread.php?t=6238
crazyhorse
Dec 17th 2004, 6:54 am
Ok tried the above doesnt seem to work, will i have to clear the page tail file as well, btw will this code creat a foot note as well on normal html pages.
This is how my htaccess file looks like
RewriteRule ^forums.* /forum/index.php [L,NC]
RewriteRule ^post-([0-9]*).html&highlight=([a-zA-Z0-9]*) viewtopic.php?p=$1&highlight=$2 [L,NC]
RewriteRule ^post-([0-9]*).* viewtopic.php?p=$1 [L,NC]
RewriteRule ^view-poll([0-9]*)-([0-9]*)-([a-zA-Z]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&vote=viewresult [L,NC]
RewriteRule ^about([0-9]*).html&highlight=([a-zA-Z0-9]*) viewtopic.php?t=$1&highlight=$2 [L,NC]
RewriteRule ^about([0-9]*).html&view=newest viewtopic.php?t=$1&view=newest [L,NC]
RewriteRule ^about([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 [L,NC]
RewriteRule ^about([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2 [L,NC]
RewriteRule ^about([0-9]*).* viewtopic.php?t=$1 [L,NC]
RewriteRule ^about([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L,NC]
RewriteRule ^mark-forum([0-9]*).html* viewforum.php?f=$1&mark=topics [L,NC]
RewriteRule ^updates-topic([0-9]*).html* viewtopic.php?t=$1&watch=topic [L,NC]
RewriteRule ^stop-updates-topic([0-9]*).html* viewtopic.php?t=$1&unwatch=topic [L,NC]
RewriteRule ^forum-([0-9]*).html viewforum.php?f=$1 [L,NC]
RewriteRule ^forum-([0-9]*).* viewforum.php?f=$1 [L,NC]
RewriteRule ^topic-([0-9]*)-([0-9]*)-([0-9]*).* viewforum.php?f=$1&topicdays=$2&start=$3 [L,NC]
RewriteRule ^ptopic([0-9]*).* viewtopic.php?t=$1&view=previous [L,NC]
RewriteRule ^ntopic([0-9]*).* viewtopic.php?t=$1&view=next [L,NC]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^forum.domainname.nl$
RewriteRule ^(.*)$ http://www.domainname.nl/forum [R=301,L]
Im using this htaccess file in the root of the forum, my other html pages are not in the same root, they are closer to the root. Will one htaccess file do and where to place the passthrough file in order to get them both working, they aint in the same folder(root).
Anyone got any ideas on what to do next much appreciated :p
In the meantime i have been trying somethings myself, it all works i aint getting an error but the ads dont show up on my html pages.
trafficjam
Dec 20th 2004, 12:03 pm
Shawn,
Your directions are excellent. I've got ads!
While I am a programmer I don't know php (yet).
Thanks much.
Foxy
Dec 21st 2004, 9:54 am
Shawn,
Your directions are excellent. I've got ads!
While I am a programmer I don't know php (yet).
Thanks much.
Oh.... there is no doubt about that....the man is right up there :)
Sometimes however the tweeking of different systems by different people cause problems!
I suddenly [bit slow these days] realised that I had a rewrite working on one of my sites so I went and tried it there.
In its form as given above it would not work in the htaccess file but as
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
it would with the escape backslashes [ie no 500 error] except that it gave a T error on the passthru.php
Any ideas?
Don't you just love it?...hehehehe
Patient
Dec 21st 2004, 10:09 am
Can you provide an example filename.
I have seen this occur on pages that I made xml compliant and had <?xml version="1.0" encoding="iso-8859-1"?> in them. It didn't like it and gave a T error - I removed it and it then worked.
PS wasn't using passthru - just processing php in htm.
ronredlich
Dec 23rd 2004, 9:42 am
Please help.
I can't get the ads to work on my site:
http://www.1st-online-mall.com
support@phpwebhosting.com reports:
Yes, mod_rewrite is available. It is installed by default on all servers. Just add your own custom mod_rewrite rules to .htaccess and it will work.
bloodwrath
Dec 25th 2004, 12:13 am
Hey all had the 500 error as well till...
is did this, it worked great for the ads
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
but it removed all my title tages & centered some of my pages
and wiped out my css on some pages
here is the page
http://www.supportcave.com/hijackthis.html
here with .htaccess file
http://www.supportcave.com/images/mod_changes.PNG
is this wierd , did this on some pages
all the ads showed but this is messed
Spyware Remover
Dec 25th 2004, 3:26 am
Is anyone here hosted on "iPowerweb"??????
I have been unable to get the ad network working and no one has an answer.
AJ
a3196
Dec 28th 2004, 8:29 pm
I used to get 500 error,,,
And i'm a Ipowerweb user...
It seems like many people are using Ipowerweb...
It works now by using code below
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
only difference is \ before .htm and .html....
Great tool anyway...
ImVickieB
Dec 28th 2004, 9:14 pm
Can anyone help with this issue?
I currently have the following in my htaccess file in order to allow me to treat html files like shtml and allow virtual includes:
AddType text/x-server-parsed-html .htm .html
When I try adding the code above in, it works, but makes the AddType above not work. I NEED that above to work as my site relies heavily on includes.
Can anyone tell me if is possible to combine the two in order to allow both to work on my site?
Spyware Remover
Dec 29th 2004, 4:46 pm
a3196:
Thanks.
What code are you using on your html pages to call up the files?
AJ
a3196
Dec 29th 2004, 11:26 pm
Hi, AJ
You don't need to put any code in any of your HTML files,,,
.htaccess file and passthru.php file will put ad on every html pages before body tag.
And you can change how they look by changing format on passthru.php
And I'm using iPowerweb and the code in .htaccess is little bit different
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
This is what I'm using....
Posted by someone,,,Can't remember...
I hope you can make it works,,,,
Spyware Remover
Dec 30th 2004, 3:44 am
Thanks!
So what you are saying is that I DO NOT need to put/make any reference on my pages to passthru.php? because the .htaccess code automatically places the ad code in front of </body>?
AJ
ImVickieB
Dec 30th 2004, 4:28 am
Thanks!
So what you are saying is that I DO NOT need to put/make any reference on my pages to passthru.php? because the .htaccess code automatically places the ad code in front of </body>?
AJ
That's right AJ :)
Spyware Remover
Dec 30th 2004, 6:13 am
GENIUS!!! It works.
Now......what do I need to edit in passthru.php to change the number of ads shown????
AJ
a3196
Dec 31st 2004, 3:22 am
That's right!!,,,
Now,, I will see some of your links in my site as well,,,
Happy new year everone...
jema
Dec 31st 2004, 9:55 am
this is probably not going to add much to the thread. But I got the 500 error as well and made my .htaccess:
RewriteEngine On
# Uncomment following line if your webserver's URL
# is not directly related to physival file paths.
# Update YourMamboDirectory (just / for root)
# RewriteBase /YourMamboDirectory
#
# Rules
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php
<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*buy).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*buy).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
Which worked for me, partially as I have only a very few .htm files on the site, but I am still at a loss as to what the 500 issue is about :confused:
trouble with this sort of thing is that with a live site, you don't want to piss about breaking it, when you get it workign you leave it.
jema
bloodwrath
Dec 31st 2004, 11:45 pm
Hi can anybody help me with this issue
Hey all had the 500 error as well till...
is did this, it worked great for the ads
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
but it removed all my title tages & centered some of my pages
and wiped out my css on some pages
here is the page
http://www.supportcave.com/hijackthis.html
here with .htaccess file
http://www.supportcave.com/images/mod_changes.PNG
is this wierd , did this on some pages
all the ads showed but this is messed
GuyFromChicago
Jan 1st 2005, 11:20 am
How would the passthru.php need to be changed to center the ad on the .htm or .html page?
dcristo
Jan 6th 2005, 8:45 am
What it will do is read any .htm or .html file, and insert the ad before the </body> tag. You can change it up to adjust formatting or for multiple ads, but it should be a start for those that need it.
Shawn, is it possible to apply this to .shtml files aswell?
digitalpoint
Jan 6th 2005, 8:46 am
Not sure, never tried.
dcristo
Jan 6th 2005, 8:49 am
I tried doing it as suggested in your initial thread and got a 500 error.
Then as suggested in another post edited these lines in the .htaccess file:
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
And this resolved the 500 error issue, but the ads still werent showing...
Perhaps its because Im using shtml files.
digitalpoint
Jan 6th 2005, 8:51 am
It's possible... if you have access, check your error log for apache on the server.
dcristo
Jan 6th 2005, 8:52 am
Can you check the error log through Cpanel?
digitalpoint
Jan 6th 2005, 8:53 am
No idea, I don't use cpanel.
dcristo
Jan 6th 2005, 8:54 am
Ok cheers mate, thanks anyway.
jeff123
Jan 9th 2005, 10:53 am
This is what worked for me. Have to do some more testing though.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /passthru.php?file=index.htm
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html$ [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
Note the $ sign after html and htm. Also had to add a special case for the home page.
Foxy
Jan 10th 2005, 12:21 am
Thanks for this one - it gave me some hope
Unfortunately it only works on the index page with a "placed" code on the page, even with or without the special case for the index page.
It appears not to be picking up the passthru file.
However at least it is not the dteaded 500 :)
pstatus
Jan 20th 2005, 3:12 pm
Shawn got my site back into working order using your passthru.php ADS appear on all pages except
index.html
it is the only page that is an html.
the rest are extensions .htm
anysuggestions????
http://www.homeloanhawaii.com
pstatus
Jan 20th 2005, 5:29 pm
Nevermind i read a thread on it... got it up and running finally. Thanks for everyone's help
Blogmaster
Jan 20th 2005, 5:39 pm
Can you check the error log through Cpanel?
Yes you can!
leonardlee
Jan 20th 2005, 10:34 pm
include ('ad_network.php');
echo preg_replace ("/<\/body>/i",
$ad_network[0]
$ad_network[1]
$ad_network[2]
. '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
leonardlee
Jan 21st 2005, 12:18 pm
too late to delete my last post I found the answer.
seoxperts
Jan 21st 2005, 11:51 pm
SHAWN..............WHERE ARE YOU ? I CAN"T HELP MYSELF SHOUTING.
I NEED TO SAY, YOU ARE GREAT. SOLVED A LOT OF MY PROBLEMS.
THANKS.
excuse me guys for shouting.
Haichi
Jan 27th 2005, 7:02 am
Oh, here's the instructions I got...
1. Place this code in your .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
2. Create a new file in the root folder titled "passthru.php" and insert this code:
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
3. Create a new file in the root folder titled "ad_network.php" and insert this code:
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
if (!function_exists('make_seed')) {
function make_seed() {
list($usec, $sec) = explode(' ', microtime());
return (float) $sec + ((float) $usec * 100000);
}
srand (make_seed());
}
if (!isset($_SERVER)) $_SERVER = $HTTP_SERVER_VARS;
$ad_file = 'ad_network_ads.txt';
for ($i = 0; $i <= 11; $i++) {
$p = substr ('../../../../../../../../../../', 0, $i * 3);
if (file_exists ($p . $ad_file)) {
$ad_file = $p . $ad_file;
break;
}
}
if (is_writable ($ad_file)) {
$ads = file_get_contents ($ad_file);
$ads = explode ('<ad_break>', $ads);
if (count ($ads) < 401 || $ads[0] + 900 < time()) {
$new_ad = file_get_contents ('http://ads.digitalpoint.com/network.php?s=' . $_SERVER['SERVER_NAME'] . '&type=link');
$ads[] = $new_ad;
$ads[0] = time();
if (count ($ads) > 401) unset ($ads[1]);
if ($new_ad) {
$file = fopen($ad_file, 'w');
fwrite ($file, implode ('<ad_break>', $ads));
fclose ($file);
}
$ad = end ($ads);
} else {
$ad = $ads[rand(1,count($ads) - 1)];
}
$ad_network[] = $ad;
while (count ($ad_network) < 5) {
$ad_network[] = $ads[rand(1,count($ads) - 1)];
}
} else {
$ad_network[] = 'You must set the "ad_network_ads.txt" file to be writable.';
}
if (substr (@$_SERVER['DOCUMENT_NAME'], -6) == '.shtml') {
ini_set ('zlib.output_compression', 0);
echo end ($ad_network);
}
?>
4. Create a new file in the root folder titled "ad_network_ads.txt" and leave it empty. Also change the file permissions to 777.
I'm trying to do this for DREAMHOST and got a 500 error
which one is the root folder at dreamhost
I have a few domains hosted with them
is / the root folder?
which has folders of all my sites...
or is it /kreyol.com?
the site I want to run the ads on
Haichi
Jan 27th 2005, 7:14 pm
I got the normal ads to work when I post the code on the page myself
but I have so many pages I need this to work
so far here is my only error the site goes blank with this error message
Parse error: parse error, unexpected T_STRING in /home/.alexa/onehaiti/kreyol.com/passthru.php on line 3
RLM Webcreations
Mar 14th 2005, 2:10 pm
I hate asking stupid questions, but I am having trouble. I generally have a fair understanding of basic programming but I am stuck.
I have followed the instructions which were very basic thank you Shaun. However, as soon asI add that snippet of code to the .htaccess file It comes up with an internal server error. I know its that because I have eliminated everything else. But as soon as I put that code in teh htaccess file. Bang no website anymore... Can anyone help?
RLM Webcreations
Mar 14th 2005, 3:01 pm
Sorry I now have it working
intensity
Mar 23rd 2005, 9:20 pm
Nice, got it.
intensity
Mar 24th 2005, 7:24 am
Has anyone here that uses subdomains have any redirecting problems after installing the script? I came to find out, by messing around with the htaccess file that the rewrite rule hampers with the subdomain redirect. As soon as I remove it my subdomains work fine.
Example subdomain.Domain.com now works
With the below Rewrite Condition I can only access these file by typing in the Domain/Folder. Any help would be appreciated.
AddType application/x-httpd-php .php .htm .html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
Cygnus
Mar 25th 2005, 1:09 pm
I was futzing around trying to get it working on a site that was giving me tons of trouble.
The problem? The idiot that wrote the page I was testing on (me) forgot the </body></html> tags...so when the script looks for </body> it doesn't find anything.
Thus, check to make sure the HTML is okay...like making sure the PC is plugged in before calling the repair tech.
Cygnus
Cyclops
Apr 20th 2005, 8:14 pm
Can someone update this thread with the new updated version of the coop code attached.
Matt S
Apr 22nd 2005, 7:08 am
managed to get this working but now all my virtual includes are not displaying!
it's on an html site the .htaccess looks like this:
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
Options FollowSymLinks IncludesNOEXEC
AddType text/html .html .htm
AddHandler server-parsed .html .htm
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /passthru.php?file=index.html
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html$ [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
any help greatfully appreciated!! :)
Matt
DJRubio
Apr 27th 2005, 8:46 pm
The only real advantage is you don't have to add the PHP code to all the files.
Wow! This is a GREAT advantage!
I was wondering how could I change my 350 html content pages without messing things up!!:D
thanks!
doggox
May 9th 2005, 8:15 am
I know I'm goin to sound a bit silly here, but I have read throught this entire post a couple of times and tried all sort of combinations for the .htaccess file, but I still can't get any ads to show up.
When I try to validate, i get the "no ads found on...."
The best thing that has happened to me all day was having the .htaccess file present without the 500 errors, or these ones
"Warning: main(ad_network.php): failed to open stream: No such file or directory in /home/fuzzypoi/public_html/doggox/passthru.php on line 12
Warning: main(ad_network.php): failed to open stream: No such file or directory in /home/fuzzypoi/public_html/doggox/passthru.php on line 12
Warning: main(): Failed opening 'ad_network.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/fuzzypoi/public_html/doggox/passthru.php on line 12"
I've tried adding in the "AddType application/x-httpd-php .php .htm .html " line before the "<IfModule mod_rewrite.c>....etc"
I've tried adding a \ before the .htm and .html
"RewriteCond %{SCRIPT_NAME} ^(.*)\.htm [NC,OR]
RewriteCond %{SCRIPT_NAME} ^(.*)\.html [NC]"
I've added 2 apache handlers because I'm using cpanel
.htm server-parsed
.html server-parsed
do these need to into the .htaccess file?, if so where?
all my pages are .htm and my server supports PHP
I've tried to put the .htaccess in my \publichtml and my subdomain root directory.
Can anyone offer me some suggestions...
Cheers
Nick
Okay I finally figured it out!!!
I had to change the pointer in the passthru.php file
from ad_network.php to ad_network_251.php
Thanks to all of this forum for all the ideas!!
l234244
May 20th 2005, 7:23 am
Is it ok to use this system to add a sitewide link to a website. For example add something like:
<? include ('test.htm'); ?> in the passthru.php file and have a standard link in test.htm
Haichi
May 29th 2005, 4:32 pm
I finally got this to work but my only problem is I can't get it to fit well with my site's design template
http://www.kreyol.com/history.html
the ads are showing up behind the top logo
I've been trying to create a footer for this template but my coding is rusty
I also have a section of my site that used frames I would have to redesign that.
City2
Jun 4th 2005, 10:39 pm
Thats really smart. Thanks
Colleen
Jun 5th 2005, 8:26 am
managed to get this working but now all my virtual includes are not displaying!
it's on an html site the .htaccess looks like this:
any help greatfully appreciated!! :)
Matt
After trying this method for html pages, I finally got it to somewhat work using Matt's code above, except one thing, instead of the internal server error, it's putting just a "<" in my pages at the very bottom.
In the code of my page I see "<</body>"
Anyone know how I can fix this and make the ads actually show? Thanks.
Site is http://www.directorysource.info
protesto
Jun 5th 2005, 10:53 am
I need to put the ads on a bunch of .htm files and also a .php file on my root folder (all without a footer file). I think the setup mentioned here works if all the files on the root folder are .html or .htm, which is not really my case. Could anybody help me on this?
Thewormman
Jun 5th 2005, 4:34 pm
Have seen this thread keep coming up, has anyone mentioned using the very simple:
XBitHack full
in the htaccess file so all html and htm files you want to will act as shtml and process the one line shtml include, WITHOUT changing any extentions?
Probably been mentioned somewhere else... :)
Yell if anyone wants to know how.
Colleen
Jun 5th 2005, 4:56 pm
Have seen this thread keep coming up, has anyone mentioned using the very simple:
XBitHack full
in the htaccess file so all html and htm files you want to will act as shtml and process the one line shtml include, WITHOUT changing any extentions?
Probably been mentioned somewhere else... :)
Yell if anyone wants to know how.
Hello Thewormman, I would like to know how since the ads aren't working for me using the other methods in this thread. Thanks.
Daniel
Jun 5th 2005, 5:10 pm
Have seen this thread keep coming up, has anyone mentioned using the very simple:
XBitHack full
in the htaccess file so all html and htm files you want to will act as shtml and process the one line shtml include, WITHOUT changing any extentions?
Probably been mentioned somewhere else... :)
Yell if anyone wants to know how.
This can also be done server wide. If your host is willing they can make htm, html, shtml, and any other extension of their choice will act as shtml and execute the SSI script.
:D
Colleen
Jun 5th 2005, 5:25 pm
This can also be done server wide. If your host is willing they can make htm, html, shtml, and any other extension of their choice will act as shtml and execute the SSI script.
:D
Well, my pages have been sitting there fucked all day cause no one will help. I could show the ads with php pages, but I'd prefer to keep them as html and all that's being displayed is "<" at the bottom of my page, not very useful.
Daniel
Jun 5th 2005, 5:28 pm
Well, my pages have been sitting there fucked all day cause no one will help. I could show the ads with php pages, but I'd prefer to keep them as html and all that's being displayed is "<" at the bottom of my page, not very useful.
is the page extension .shtml?
Let me look at the code. Ill fix the SSI call if the syntaxt is wrong. but your webhost has to have SSI enabled and usually by default the page extension has to be .shtml to parse the script through an SSI call.
Colleen
Jun 5th 2005, 5:32 pm
Yeah, but we're doing something here so we don't have to change the extension. But if I have to resort to .shtml well then... it's the .htaccess shit, what Shawn posted wouldn't work for me, but what Matt posted worked, as in no internal server error but the ads are not displaying.
Daniel
Jun 5th 2005, 5:34 pm
Yeah, but we're doing something here so we don't have to change the extension. But if I have to resort to .shtml well then... it's the .htaccess shit, what Shawn posted wouldn't work for me, but what Matt posted worked, as in no internal server error but the ads are not displaying.
Babe the web host can modify the /usr/local/apache/conf/httpd.conf file to allow all extension to parse script through SSI calls.
ie. all pages would work and the ads will display.
When you say your doing something you mean you and the host?
If so then he is probably making the modifications Im talking about as we speak :D:D
Colleen
Jun 5th 2005, 5:39 pm
Babe the web host can modify the /usr/local/apache/conf/httpd.conf file to allow all extension to parse script through SSI calls.
ie. all pages would work and the ads will display.
When you say your doing something you mean you and the host?
If so then he is probably making the modifications Im talking about as we speak :D:D
Not me and the host. I already know I can do the SSI way. I meant this thread, what IT's trying to help us do. :)
I can already show the ads using php or ssi, but then I saw this thread and that I could keep my FILENAME as html and that's what I prefer so I tried it and have been having issues.
Daniel
Jun 5th 2005, 5:46 pm
Not me and the host. I already know I can do the SSI way. I meant this thread, what IT's trying to help us do. :)
I can already show the ads using php or ssi, but then I saw this thread and that I could keep my FILENAME as html and that's what I prefer so I tried it and have been having issues.
ok hehehe
.shtml is SSI
you are trying to get html and htm etc to do the same thing that .shtml does right?
Either the HOST (Server Admin) can modify the httpd.conf file to include these two lines or you can put them in your .htaccess file.
I setup my servers with these lines to make the .shtml stuff work across .htm and .html pages as well as .shtml
AddType text/html .shtml
AddHandler server-parsed .shtml .htm .html
Colleen
Jun 5th 2005, 5:55 pm
ok hehehe
.shtml is SSI
you are trying to get html and htm etc to do the same thing that .shtml does right?
Either the HOST (Server Admin) can modify the httpd.conf file to include these two lines or you can put them in your .htaccess file.
I setup my servers with these lines to make the .shtml stuff work across .htm and .html pages as well as .shtml
AddType text/html .shtml
AddHandler server-parsed .shtml .htm .html
I know for sure it works on my hosts server. It's what I am trying to do now that won't work. :(
If you just set-up PayPal, Daniel, I'd pay you for hosting and then you can fix all my problems on command, k?! :rolleyes:
Daniel
Jun 5th 2005, 5:57 pm
I know for sure it works on my hosts server. It's what I am trying to do now that won't work. :(
If you just set-up PayPal, Daniel, I'd pay you for hosting and then you can fix all my problems on command, k?! :rolleyes:
and what you are trying to do now is to get .shtml code to work with a .html extension right? :confused:
Colleen
Jun 5th 2005, 6:02 pm
and what you are trying to do now is to get .shtml code to work with a .html extension right? :confused:
I don't even know anymore. :( It's in the first post.
Infiniterb
Jun 5th 2005, 6:37 pm
It sounds like Lady is trying to get .html/.htm files to display the co-op code using what shawn provided in the first post of this thread. The problem here is that some hosts won't process the code in the .htaccess file. Matt's example works, but Shawn's, for some reason, doesn't.
Thewormman
Jun 5th 2005, 11:54 pm
Maybe no-one has talked about the method I mentioned :eek:
AddType text/html .shtml
AddHandler server-parsed .shtml .htm .html
The trouble with this is it makes the server parse ALL the pages as shtml which takes a bit longer.
Anyway, that method never worked for me but this method did and is really simple.
1. Put the line
XBitHack full
in your root htaccess file at the top so it gets processed first.
2. Place the shtml include code for the ads in your html page where you want them to show.
3. Chmod your permissions on that page as 755 executable.
Now every time the page is called, as long as you can process server includes with your hosting set up, that page will be parsed as well.
Any html pages you don't want to parse just leave permissions as 644 usually the default.
This will only work with Apache servers.
Another advantage is that no-one knows you are adding things dynamically as you still show the static html extension.
Thats it! :D
Reference: http://httpd.apache.org/docs/howto/ssi.html
success108
Jun 7th 2005, 2:36 pm
Hi I'm a newbie, still learning
1. Put the line
XBitHack full
in your root htaccess file at the top so it gets processed first.
Does this mean you can have multiple "funcitions" in the root htaccess file? I already have one and I don't want to screw it up.
2. Place the shtml include code for the ads in your html page where you want them to show.
Do you mean this? <!--#include virtual="/ad_network_###.php" -->
3. Chmod your permissions on that page as 755 executable.
Is this necessary? If it is, is there a way to change the permission of multiple pages at once in C panel, I have a lot of pages.
Thewormman
Jun 7th 2005, 3:41 pm
Does this mean you can have multiple "funcitions" in the root htaccess file? I already have one and I don't want to screw it up.
Yes, but make a backup and always check immediately to make sure there are no conflicts with what is in there already.
Do you mean this? <!--#include virtual="/ad_network_###.php" -->
Yes
Is this necessary? If it is, is there a way to change the permission of multiple pages at once in C panel, I have a lot of pages.
As far as I know you have to change each page in cPanel. Try using an ftp program like WS_FTP Pro from www.ipswitch.com it allows you to highlight and change all the contents of directories in one go and it is free to download.
kdobson99
Jun 7th 2005, 4:18 pm
After reading this thread, I am a little confused at the various approaches. I am not a good programmer but can follow directions halfway decent... Can someone give me the most simple way to get MULTIPLE ads to display with the following setup...
The main content pages of the site are php based, however it was originally designed to include an html footer file, rather than a php footer. I don't really want to change this on the various pages, but I want to put the ad code in the html footer file. I have it set apache to parse html and htm as php, and I thought that would fix it, but didn't, so now I am here trying to decide which advice in this thread actually worked and which didn't etc. Mod rewrite is supported on the server btw.
Can someone give me an ABC,123 on doing it with this setup. Again, I want to display 5 ads in the html footer file.
Thanks
success108
Jun 7th 2005, 6:03 pm
Thanks for answering my questions wormman.
davshirley
Jun 12th 2005, 9:27 pm
To those of you that are getting 500 error code: I too had the same problem and it was because the mod-rewrite script was getting locking in an infinite loop. In addition, the rewrite condition does not take effect if a request comes in for / (your index page). Here is what I am using now:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ /passthru.php?file=index.html
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*)\.htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*)\.html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
Note the first change (RewriteRule ^$ /passthru.php?file=index.html) will make it work with requests for / assuming that your index page is named index.html. Adjust that line if your index page is named something different.
The next change is in the two RewriteCond lines. Note the \ before the .htm and .html. Their presence stops the infinite loop that I referenced earlier. I have no idea way. Some servers that I use require the \ by there and others do not. I'd really love to hear the explaination if anyone has it....
Foxy
Jun 13th 2005, 1:59 am
Hi
That stopped the 500 error but I now have
Parse error: parse error, unexpected T_STRING in /home/domain/public_html/passthru.php on line 3
unfortunately
asc44
Jun 15th 2005, 5:18 am
Hi,
My ads display don't fit with the design.
How can we add a "div" tag to format ads display?
I'm guess, it's near the line of "echo preg_replace"
but I don't know how to insert additional code.
Such as, if I want to align "center" the ads, what code I've to add?
Thank you in advance for your help!
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
joeldavuk
Jun 15th 2005, 5:37 am
is there a way to make certain files be an exception to the rule?
i use the following
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) passthru.php?file=$1
</IfModule>
for example if i wanted thanks.htm to not be proccessed in this manner how would i do it?
joeldavuk
Jun 15th 2005, 5:47 am
<?php
if (!function_exists('file_get_contents')) {
function file_get_contents($url) {
$handle = fopen($url, 'r');
$string = fread($handle, 4096000);
fclose($handle);
return $string;
}
}
include ('ad_network.php');
echo preg_replace ("/<\/body>/i", $ad_network[0] . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
?>
i would replace the echo with the following.
echo preg_replace ("/<\/body>/i", "<div align=\"middle\">$ad_network[0]</div>". '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file'])));
asc44
Jun 15th 2005, 8:13 am
joeldavuk,
Thanks very much! :)
asc44
Jun 22nd 2005, 7:31 am
Hello All,
Want any experts please help.
I've tried to add DP Ads (parse through html) to another old site, but it's not success.
I've checked apache module, the module_rewrite was loaded.
I've followed to all instructions in this thread.
But it displayed no ads, no errors.
Although I've successfully done this with other server.
I've checked the apache log "/var/log/httpd/error", no errors about the module.
Can anyone help suggest how to fix the problem?
I'm really appreciate your help! :)
Thank you...
donnareed
Jun 24th 2005, 2:08 pm
Does anyone know if this method works with the latest new .php file? (the one with tracking stats etc.)?
jyoti2005
Jul 1st 2005, 9:56 am
My website keeps disappearing whenever I try to put the .htaccess file up on the server.
I put the following content into the file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} ^(.*).htm [NC,OR]
RewriteCond %{REQUEST_FILENAME} ^(.*).html [NC]
RewriteRule ^(.*) /passthru.php?file=$1
</IfModule>
I checked my error log and got the following:
"mod_rewrite: maximum number of internal redirects reached. Assuming configuration error.
Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary."
What should I do?
Thanks!
GADOOD
Jul 27th 2005, 9:14 pm
Man, I thought about joining the coop until I read this thread and all the complexities of setting it up on a .html site. Bollocks to that, it's nigh impossible to understand any of it and I've been making websites for 10 years! You have to be a super nerd or something. I guess I'll just keep working at my link building instead. Jesus! :mad:
Memories of trying to play a hard tune on the piano when I was 11 are flooding back and I'm getting angry instead of upset this time.. at no-one inparticular. Just angry. :p
Pete
Cyclops
Jul 27th 2005, 9:20 pm
:D Join the club..it is daunting and I felt the same as you, however I found there are some nice people here at DP who will do it for you....usually for a small fee :)
It really is worth perserving with though so don't give up too soon.
Foxy
Jul 28th 2005, 12:12 am
Man, I thought about joining the coop until I read this thread and all the complexities of setting it up on a .html site. Bollocks to that, it's nigh impossible to understand any of it and I've been making websites for 10 years! You have to be a super nerd or something. I guess I'll just keep working at my link building instead. Jesus! :mad:
Memories of trying to play a hard tune on the piano when I was 11 are flooding back and I'm getting angry instead of upset this time.. at no-one inparticular. Just angry. :p
Pete
Why are you getting angry?????
This is for free ....... I can't get it to work on my html pages either ....but that is not the fault of Shawn or the coop....that is the fault of the servers and how they react with the code.
So chill out a little and take what is good from here.
You may need to change your site to php, which is quite easy, and then the problems just disappear, and I can assure you that the time taken to do that is a lot less than looking for reciprocals!!!!;)
fryman
Jul 28th 2005, 12:26 am
Heck, I had to pay some guy 50 bucks to modify some things in my site and get the coop to work :D
Whining about it won't help you at all... if you can't figure it out, either get someone to do it for you, or just forget about it
ronmojohny
Jul 30th 2005, 10:46 pm
I want to ad my site to the coop. I know very basic HTML, but this stuff is a bit beyond my skill level. My site is all in html. (maybe 7 pages total) I think I have a page rank of 2. And I found out that it is an Apache server. Would someone offer to help place the code into my site for me? I would never get it to work.
Thanks, RonMo
l234244
Jul 31st 2005, 1:33 am
The first page of this topic has all the information you need, do what it says and post any problems you may had.
Cyclops
Jul 31st 2005, 5:21 am
I'm not sure but I think Shawn made some changes to the coop script making the code on the first page of this thread redundant.
l234244
Jul 31st 2005, 1:44 pm
I think one of my sites is using this code and still functioning, better go and check
dcristo
Sep 12th 2005, 5:08 am
Just to give a heads up, it is now a requirement to make the changes to the coop in order to continue working. For those using the coop on htm/html pages with the passthru method and are still using the old code, the new passthru code should be as follows:
<?php if (!function_exists('file_get_contents')) { function file_get_contents($url) { $handle = fopen($url, 'r'); $string = fread($handle, 4096000); fclose($handle); return $string; } } include ('ad_network_377.php'); echo preg_replace ("/<\/body>/i", $ad_network . '</body>', file_get_contents(str_replace ('../', '', $_REQUEST['file']))); ?>
This code applies whether your displaying 1 or 5 ads, it's the same regardless. You specify the no. of ads you want to display in the new ad_network_377.php file.
In addition to this, just make updates to the new ad_network_377.php file and upload an empty ad_network_377.txt file, and make sure to chmod 666 it.
Hope that helps.
aquila99
Sep 13th 2005, 7:14 am
Hello from Italy, I find that the co-op idea is great. I have spent some hours trying to get the codes to work and fixing, to no avail.
my knowledge is limited to html and some cgi, and I can make changes in the .htaccess, as well as ftp and give server permissions, but I am primarily a content writer and can see that this is possibly out of my reach..I have very little knowledge of php.
This is the error I use to get:
Warning: main(ad_network.php): failed to open stream: No such file or directory in /web/htdocs/www.italyworldclub.com/home/passthru.php on line 1
Warning: main(): Failed opening 'ad_network.php' for inclusion (include_path='.:/usr/local/lib/php') in /web/htdocs/www.italyworldclub.com/home/passthru.php on line 1
Thanks to anyone who can put me in the right direction.
digitalpoint
Sep 13th 2005, 10:52 am
Do you have a file named exactly ad_network.php in the same folder as your passthru.php file?
aquila99
Sep 14th 2005, 5:53 am
Yes, the file is there.
The files I installed as per digital point instructions are:
ad_network_378.php
ad_network_ads_378.txt
passthru.php
And I made the suggested changes in the .htaccess
If you think seeing the files can help understanding the problem, I will send them in the form you tell me.
digitalpoint
Sep 14th 2005, 8:57 am
ad_network_378.php is not the same file name as ad_network.php.
dcristo
Sep 14th 2005, 9:18 am
Dude, in the passthru code you want to make sure you properly reference the ad_network_378.php file.
daman69xo
Apr 7th 2006, 9:51 pm
Is there a clear cut way to get the coop to work on html or htm pages?
From the early posts, the codes have evolved. I see some using php
<?php
ini_set ("include_path", ini_get ("include_path") . ':../:../../:../../../:../../../../');
include ('ad_network_xxx.php');
echo $ad_network;
?>
or
<!--#include virtual="/ad_network_xxx.php" -->
in areas where they want the ads to be displayed. I also read that the permission should be set at 755 and then i saw other posts that said it should be at 666.
Which one is right??
yipesft
Jun 28th 2007, 7:33 am
Working on getting this set up on my html based site.
In looking at the error logs, I see:
[Thu Jun 28 08:31:34 2007] [error] [client 68.127.48.251] mod_rewrite: maximum number of internal redirects reached. Assuming configuration error. Use 'RewriteOptions MaxRedirects' to increase the limit if neccessary.
Website is currently displaying a 500 internal server error:
'Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request."
Any thoughts?
thundercow
Mar 10th 2008, 12:02 pm
Well I am getting an internal configuration error if I set this up the way it is in this thread. And I KNOW my server is configured for mod_rewrite because I successfully installed the mod_rewrite mod to my phpbb installation.
Any thoughts on why I'd be getting this error?
Here's my existing .htaccess file, if this illuminates the issue, maybe that xbithack is messing it up.
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
XBitHack on
<Limit GET POST>
#The next line modified by DenyIP
order allow,deny
#The next line modified by DenyIP
#deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName www.learnaboutlaw.com
AuthUserFile /home/ll34rn/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/ll34rn/public_html/_vti_pvt/service.grp
<Files 403.shtml>
order allow,deny
allow from all
</Files>
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.