Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

include 2

Status
Not open for further replies.

sonun

IS-IT--Management
Dec 26, 2001
384
US
how do I do a include of one html file in another file. I thought putting it is as,
<!--#include file=&quot;./top.htm&quot;-->
within the body tags would do. BUt that didnt seemed to work.
Please advise.
Thanks.
 
can't...how ever you can include an .asp page in another html page

even if the asp page has no asp code....

hth

Bastien

There are many ways to skin this cat,
but it still tastes like chicken
 
Hi guys,

Bastien, you can do this. It is called SSI. (Server Side Includes)

Rename your page to .shtml and try that.

If that doesn't work, use the following code:

<!--#include virtual=&quot;path/to/my/file.shtml&quot; -->

The file that you include can be virtually any static page, if the file that you include is a .shtml file then you can also use nested include statements on that page as well.

If you want to execute a cgi script then the following code may also be used:

<!--#exec cgi=&quot;/path/to/my/file.pl&quot; -->

There are also quite a few more advanced things that you can do with SSI such as, display browser version, IP, Date & time etc, but these use a different syntax.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
how do Icheck if it doesn not support ssi's
 
Yes I can see the include statement. So, it does not work. Then how do I make it work for a Redhat7.1/ Apache servers.
Thanks.
 
in the /apache_home/conf/httpd.conf
There was a commented bit of .shtml which I uncommentd to look like this. But this still dont work.
#
# To use server-parsed HTML files
#
AddType text/html .shtml
AddHandler server-parsed .shtml

Please advise.
 
Hi mate,

This is really a question for the Apache froum but I will answer it here anyway since it does relate to this thread.

You will have something like the following for you root directories:

AllowOverride None
Options None
Order allow,deny
Allow from all

You need to change them to add the option Includes.

AllowOverride None
Options Includes
Order allow,deny
Allow from all

Then restart Apache and try again.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
gotcha !!
That works, but why does it seems like I now have to rename all files as .shtml now.
Is that the case or am I missing something.
Thanks.
 
Hi mate,

The reason for that is because you have specified .shtml for SSI.

AddType text/html .shtml
AddHandler server-parsed .shtml

Now, you can add .html to that statement but if your server has a high turnover of visitors then it starts to get resource intensive.

Whatever extension you specify, the server ALWAYS looks for SSI in that file so even if you only had one html file that actually has SSI calls, every single file is still parsed for SSI.

If you still want to do it then the following syntax should be used.

AddType text/html .shtml
AddHandler server-parsed .shtml .html

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
That did help mate !!
I couldnt give you a star as there was a error processing the request. I have notified the admin@tek-tips though.
Thanks again.
 
Good job Wullie!!


É

endamcg-logo1b.gif

 
No problem guys..

Just a note for anyone that wants to change the extension for SSI but does not have access to the actual config for Apache.

You can still change this without access to the httpd.conf as long as you have full control with htaccess files.

Just add the following lines to a htaccess file in whatever directory you want this change to take effect.

AddType text/html .shtml
AddHandler server-parsed .shtml .html

The same warning applies as above though.

Hope this helps

Wullie

sales@freshlookdesign.co.uk

 
Sorry, I just had this thought at the back of my head for sometime. But what is the htaccess thing for. I thought htaccess was for limiting access to pages and stuff. Never really tried it though. Good links for that would be great !! But again the question is how does your last suggestion work ??
edit:
Just add the following lines to a htaccess file in whatever directory you want this change to take effect.

Thanks.
 
Hi mate,

Htaccess can be used for loads of things.

The most common use for htaccess is User Authentication which is just basically password protection of directories.

Basically, htaccess can specify anything locally that you specify globally in the httpd.conf. (with a few exceptions)

So, this allows you to host people and for them to have different configs for their own domain.

For example, the following can be used in the httpd.conf:

Ridirect /oldpage.html
If one of your users wanted to implement this, they could add it to a htaccess file and do it all themselves, rather than having to contact you and get you to do it for them in the httpd.conf.

I have never found a good tutorial on htaccess but if you visit the Apache site and take a look at all the directives, if they specify that they can be used in the VHost directives then they will also work in htaccess files.

To ebable htaccess to be able to do all of this your httpd.conf must have the following for the directory in question or globally:

AllowOverride All

If you just want to specify that only User Authentication can be used then the following should be applied:

AllowOverride AuthConfig

The AllowOveride just tells Apache what a htaccess file can actual override in the httpd.conf. So if you specify config for a directory in the httpd.conf and have the above statement allowing htaccess to override it, then any htacces in those directories would in effect make your global config not be used.

Remember though that whatever you specify in a htaccess file also applies to any subdirectories of that folder unless they have their own htaccess file.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Getting bit and pieces of it. Can you post a sample htaccess file, plzzz.

Have another doubt which I guess is related. How good a thought is it to have all pages loaded through https. I have compiled apache with ssl and openssl. So it does allow for encrpted transmission (I guess !!). So if I on my website href all my links to &quot; &quot; then all the tranmissions over the network will be encrypted. But is there a better way than that becuase sometimes you dont alwyas specify the full url as in,
<a href=&quot; <H1>News and Events</H1> </a>
Sometimes you do a relative <a href=&quot;../another.html&quot;>

and also I did a fair bit of seraching for shtml (atleast for the abbreviation), but couldnt get what I wnted. More, I found pages as jhtml, etc. So what are these things and shtml got anything do with security as in secure html.

Thanks a bunch.
 
Hi mate,

shtml in no way means secure html.

shtml is just the file extension that tells Apache to parse the file for SSI before sending it to the browser.

SSL is a totally different subject and not one that should really be covered in this forum as it is not related.

If you have questions about Apache related SSL then the Apache forum is the place for them.

Hope this helps Wullie

sales@freshlookdesign.co.uk

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top