LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   apache 2 not recognizing .shtml files (https://www.linuxquestions.org/questions/linux-newbie-8/apache-2-not-recognizing-shtml-files-766942/)

lilmike 11-04-2009 08:29 PM

apache 2 not recognizing .shtml files
 
Hi,
I have just changed my web pages mostly to .shtml to take advantage of ssi.
Now, when I go to my website, it gives an "index of /" page instead of showing the .shtml files.
I have read in many places that .shtml files have to be specifically set up to be recognized as index files, but I cannot for the life of me get it to work or even to understand where I'm supposed to put all of the configuration stuff.
I need to know what to change to make the apache 2 parse .shtml files for ssi and also to make apache check for .shtml files as an index file.
Any help would be appreciated.
Thanks,
-Michael.
P.S. I would also like to know how to make it so it will not by default show an "index of /" or whatever page when it does not find an index file.
Also, I would need to know how to turn off this behavior for a particular directory.

bathory 11-05-2009 12:17 AM

Hi,

You have to add index.shtml in the DirectoryIndex directive.

For apache to parse .shtml pages (pages with ssi includes) you need to add
Code:

AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

among the other AddType directives and the keyword "Includes" to the Options of the DocumentRoot directory.

If you don't want apache to do a directory listing when it cannot find an index page, then you have to remove the keyword "Indexes" from the Options of that directory.

lilmike 11-05-2009 07:45 PM

Hi,
Can you give me an example of a configuration file with this included.
Also, where should I put it, in httpd.conf, in a specific website file, in apache2.conf, or what.
Also, if it is httpd.conf, which one, the one under /etc/apache2 or /etc/apache2/conf.d
So if you could help me by providing an example, that would be nice.
-Michael.

jmc1987 11-05-2009 08:08 PM

Quote:

Originally Posted by lilmike (Post 3746398)
Hi,
Can you give me an example of a configuration file with this included.
Also, where should I put it, in httpd.conf, in a specific website file, in apache2.conf, or what.
Also, if it is httpd.conf, which one, the one under /etc/apache2 or /etc/apache2/conf.d
So if you could help me by providing an example, that would be nice.
-Michael.


There is actually 3 configuration files from when NCSA was writing it. They are still there but apache now recommends just using the httpd.conf only. So edit /etc/apache2/conf.d

Nope I guess they took the 2 other conf files out. So just httpd.conf is the one you still want to edit anyways

lilmike 11-05-2009 08:46 PM

mmk,
Now how about an example, I am hopelessly lost around these conf files.
Any help would be appreciated.
-Michael.

parkprimus 11-05-2009 10:00 PM

Did you google?
 
go to http://httpd.apache.org/docs/2.0/mod/mod_include.html and follow the documentation. If you make a change to a config you have to restart the service. But I have to ask why do you want to enable .shtml. You know if is for service side inludes, right?

lilmike 11-06-2009 02:19 PM

Quote:

Originally Posted by parkprimus (Post 3746512)
go to http://httpd.apache.org/docs/2.0/mod/mod_include.html and follow the documentation. If you make a change to a config you have to restart the service. But I have to ask why do you want to enable .shtml. You know if is for service side inludes, right?

Hi,
Yes I know this is for server side includes, that is what I have in my .shtml pages, that's why I need it enabled.
I will try the link you posted.
Thanks,
-Michael.

lilmike 11-06-2009 04:03 PM

Hi,
I went there, and under the enabling server side includes, it said basically what everyone has told me to do, but nothing about where to put it, or what to put around it, or anything.
If someone could give an example of a typical conf file, that would be nice.
Also, I have placed that text in /etc/apache2/conf.d/httpd.conf and in /etc/apache2/httpd.conf and in /etc/apache2/sites-available/<mysite.mytld> but none of it seems to work.
I reloaded and sometimes restarted the server after each changed.
Any help is appreciated.
-Michael.

bathory 11-06-2009 04:21 PM

Hi,

I think that this could help you understand what you have to edit in order for apache to use SSI.

Regards

lilmike 11-06-2009 07:59 PM

Hi,
I've got a few questions about that website now.
Do those texts mentioned have to specifically be in the <directory /var/www/> or do they have to be in a <directory> tag that corrolates to your document root, such as <directory /websites/myhost.mydomain/public_html/> if my web files were in /websites/myhost.mydomain/public_html/
Because when I put them in the default file but put them in a <directory /websites/myhost.mydomain/public_html/> because that's my document root, it stills shows the index of /
Any help, is as always, appreciated.
-Michael.
P.S. Thanks alot to all the people who have helped thus far, and I hope you can put up with me a little bit more :)

parkprimus 11-07-2009 03:39 PM

With in..
 
the <Directory> tag is a perfect place for the entry.

lilmike 11-08-2009 11:46 AM

Hi,
Thanks for the note that the <directory> tag is the place to put it.
Unfortunately, it still isn't working.
I put the text on the website mentioned in a previous post in the <directory /websites/mtgames.org/public_html/> tag, and also in the <directory /var/www/> tag, but none of it works.
It should be noted that my files for the website are not in /var/www, but in /websites/mtgames.org/public_html/
I put the modifications in the mtgames.org virtual host file, and also in the default file.
When I just put it in the mtgames.org file, it still gives me an index of /.
When I put it in the default file, however, it says access forbidden.
I did, it should be noted, remove the options indexes directive, just to test.
Here is my virtual host file along with my default file, which are all the same.
Quote:

<VirtualHost *:80>
ServerAdmin webmaster@localhost

DocumentRoot /websites/mtgames.org/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options FollowSymLinks MultiViews +Includes
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>
Any help is appreciated and thanks for all the helpful responses.
-Michael.

lilmike 11-09-2009 02:24 PM

Hi,
I am still having terrible trouble getting it to work.
I even tried using allowoverride all to do it in the .htaccess file, but no luck.
It still says access forbidden!
Any help is appreciated.
-Michael.

bathory 11-09-2009 04:27 PM

Have you added index.shtml in the DirectoryIndex directive as pointed out in the 2nd post?
Another thing you should take care, is that you have "DocumentRoot /websites/mtgames.org/public_html" for your vhost, but you change things for "<Directory /var/www/>". And you need a ServerName.
Better use this:
Code:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/websites/mtgames.org/public_html"
ServerName www.domain.com
<Directory "/websites/mtgames.org/public_html">
Options FollowSymLinks MultiViews +Includes
AllowOverride None
Order allow,deny
allow from all
# This directive allows us to have apache2's default start page
# in /apache2-default/, but still have / go to the right place
#RedirectMatch ^/$ /apache2-default/
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>

</VirtualHost>


lilmike 11-10-2009 07:27 AM

Hi,
I did exactly as you said in your post, did the exact code you put there.
Still saying access forbidden!
I have the default and the mtgames.org page as the same thing, is that right?
Also, it makes me think I'm missing something I need to do before or after reloaded apache2
So, when I modify and save the file, I do this:
Quote:

/etc/init.d/apache2 reload
And then I visit the website, and it gives me the access forbidden!
I really don't know what's wrong, but I'm sure everyone is trying their best to help me.
Thanks for a speedy reply,
-Michael.


All times are GMT -5. The time now is 05:45 AM.