Last Modified

liunx

Guest
I have been trying to find an easy way to add the "Last Modified" date to all my web pages.<br /><br />The URL is already out there so I don't want to change it to .shtml.<br /><br />Is there an easy way? I have looked at all the java versions, but am not familiar with the language. And would that require .shtml too?<br /><br />Help is appreciated.<br /><br />Pat<!--content-->
Here is some PHP code that should do it:<br /><br /><?<br />$file_last_modified = filemtime("$DOCUMENT_ROOT$PHP_SELF");<br />print("Last Modified ");<br />print(date("m/j/y h:i", $file_last_modified));<br />?><br /><br />Just insert this into your page where you want it to say "Last Modified ...".<br /><br />If you want to keep your pages .htm or .html then you'll need to modify your .htaccess file to tell it to look for PHP code in .htm files. To do that edit the .htaccess file and add the following lines:<br /><br />AddType application/x-httpd-php .htm<br />AddType application/x-httpd-php .html<br /><br />Hope it helps!<!--content-->
Jim,<br /><br />Thank you. That sounds great. Only one tiny problem... I can't seem to find the .htaccess file. <br /><br />I tried CPanel, then viewed the site via ftp, and even got brave and opened the PHPAdmin file in CPanel. <br /><br />Sorry, my newness is showing...<br /><br />Pat<!--content-->
Not at all, Pat. This stuff is strange until you get used to it.<br /><br />The .htaccess probably won't show up in an ftp program because it starts with a period. Additionally, there may not even be one. <br /><br />Go to your Cpanel. Find File Manager and click that. Click the folder icon next to public_html and it should open that folder for you. If you don't see a .htaccess file then you can create a new file and put the lines in you need. Then save and exit. Go to your site and see if it works. Remember if you have the page open to use Ctrl-Refresh to make sure the browser gets a brand new copy of your page. <br /><br />If it doesn't work then go to View Source from your browser. If you see the lines of PHP instruction then the .htaccess isn't working. If you don't see that but it doesn't put up the date modified then it may be a problem with the php part.<!--content-->
Found the .htaccess. Yea!<br /><br />I added the lines -- but I'm not sure I put them in the right place. I figured they should be near the top but not first. (Pat's logic.)<br /><br />When I went back to File Manager, it looked like there were now two different .htaccess files, one with numbers after it.<br /><br />Added the code to the web page. Uploaded it. Sheesh... Code shows.<br /><br />BUT, I found a BIG db file at my site. I don't think it belongs there. <br /><br />Back to the farm... now what?<br /><br />Pat <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/blink.gif" style="vertical-align:middle" emoid=":blink:" border="0" alt="blink.gif" /><!--content-->
 
Back
Top