My personal website, hosted on a Linux server using Apache,
contains some files with a "cs" extension:
file.cs
When visitors attempt to access those files they receive
a 403 error:
ERROR 403: Forbidden.
The solution should be to add a "cs" MIME type to the
Apache .htaccess file in the root directory:
AddType application/octet-stream cs
But when I do this the 403 error still occurs.
As temporary workaround I have added the "txt" extension
to each "cs" file:
file.cs.txt
This allows regular access but I would rather not do this
as these files are not actually human-readable.
Is there a way to instruct Apache to permit access to these
files?
"ERROR 403: Forbidden." more correctly means that the files are not "readable"
by the httpd process. Depending on the distro, this could be because the files
(or the directory they are in) are not owned by www-data (or whatever user the
httpd runs as) or you have selinux installed and enabled and the files are not
in an directory enabled for web access (eg with the proper selinux ACL). Or the files lack read access -- the file don't actually need to be owned by the user the httpd process runs under, so long as they and their parent directories have read access (the directories just need execute access to allow traversal). If the files/directories have a different group or owner, they need the proper group or world read/execute access. The MIME type only matters if that is needed for proper interpretation by the browser is an issue, but lacking a proper MIME type won't cause a 403 error. There *could* be issues if the files are symlinks and the FollowSymLinks Option is missing from <Directory> elements.
At Thu, 05 Mar 2026 13:57:03 +0000 Farley Flud <[email protected]> wrote:
My personal website, hosted on a Linux server using Apache,
contains some files with a "cs" extension:
file.cs
When visitors attempt to access those files they receive
a 403 error:
ERROR 403: Forbidden.
The solution should be to add a "cs" MIME type to the
Apache .htaccess file in the root directory:
AddType application/octet-stream cs
But when I do this the 403 error still occurs.
As temporary workaround I have added the "txt" extension
to each "cs" file:
file.cs.txt
This allows regular access but I would rather not do this
as these files are not actually human-readable.
Is there a way to instruct Apache to permit access to these
files?
On 05/03/2026 14:56, Robert Heller wrote:
"ERROR 403: Forbidden." more correctly means that the files are not "readable"Yes. It's a permissions, not a 'I can't understand the type' error.
by the httpd process. Depending on the distro, this could be because the files
(or the directory they are in) are not owned by www-data (or whatever user the
httpd runs as) or you have selinux installed and enabled and the files are not
in an directory enabled for web access (eg with the proper selinux ACL). Or >> the files lack read access -- the file don't actually need to be owned by the
user the httpd process runs under, so long as they and their parent
directories have read access (the directories just need execute access to
allow traversal). If the files/directories have a different group or owner, >> they need the proper group or world read/execute access. The MIME type only >> matters if that is needed for proper interpretation by the browser is an
issue, but lacking a proper MIME type won't cause a 403 error. There *could* >> be issues if the files are symlinks and the FollowSymLinks Option is missing >> from <Directory> elements.
Check to see who owns the files and what the perms are.
On Thu, 5 Mar 2026 15:00:59 +0000, The Natural Philosopher wrote:
On 05/03/2026 14:56, Robert Heller wrote:
"ERROR 403: Forbidden." more correctly means that the files are not "readable"Yes. It's a permissions, not a 'I can't understand the type' error.
by the httpd process. Depending on the distro, this could be because the files
(or the directory they are in) are not owned by www-data (or whatever user the
httpd runs as) or you have selinux installed and enabled and the files are not
in an directory enabled for web access (eg with the proper selinux ACL). Or
the files lack read access -- the file don't actually need to be owned by the
user the httpd process runs under, so long as they and their parent
directories have read access (the directories just need execute access to >> allow traversal). If the files/directories have a different group or owner,
they need the proper group or world read/execute access. The MIME type only
matters if that is needed for proper interpretation by the browser is an >> issue, but lacking a proper MIME type won't cause a 403 error. There *could*
be issues if the files are symlinks and the FollowSymLinks Option is missing
from <Directory> elements.
Check to see who owns the files and what the perms are.
It can't be a permissions problem because I can just rename the filesThat makes no sense. 403 is specificly a permissions issue, never a MIME
to add the "txt" extension without altering any permissions and then
the files are accessible.
What also puzzles me is that after checking the server logs there is no
403 error reported anywhere.
My .htaccess file is located in the root directory of the website tree.That should not matter.
Maybe I need to move it the directory of the web page that actually delivers those "cs" files.
It can't be a permissions problem because I can just rename the files
to add the "txt" extension without altering any permissions and then
the files are accessible.
That makes no sense. 403 is specificly a permissions issue, never a MIME type. Maybe something else is going on. Are you defining a *handler* for .cs
files? If so it might be a problem with the *handler* and not the files themselves.
Hmm... It might not really be a 403 error at all and something else is going on. What *exactly* are these .cs files?
"ERROR 403: Forbidden." more correctly means that the files are not "readable" by the httpd process.
On Thu, 5 Mar 2026 18:43:00 -0000 (UTC), Robert Heller wrote:
It can't be a permissions problem because I can just rename the files
to add the "txt" extension without altering any permissions and then
the files are accessible.
That makes no sense. 403 is specificly a permissions issue, never a MIME type. Maybe something else is going on. Are you defining a *handler* for .cs
files? If so it might be a problem with the *handler* and not the files themselves.
I first reported this problem to the Help staff at my web hosting service. They responded by telling me to use cPanel to add the MIME type for the "cs" extension. cPanel just appends the line "AddType application/octet-stream cs"The Help staff of your web hosting service are idiots. The 403 error has nothing to do with MIME types. It is specificly about permissions.
to the .htaccess file. However, that solution did not work.
The permissions on the relevant directories are 755 as they should be.What about owner and group?
The permissions on the files are 644 as they should be.
Hmm... It might not really be a 403 error at all and something else is going
on. What *exactly* are these .cs files?
The complete error message that is shown in a browser is this:This suggests that the owner, group, and persmissions of the Error Document
Forbidden
You don't have permission to access this resource.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
The .cs files are Tcl scripts that are modified to be used with
a certain program. They are basically text files that contain Tcl commands.
As I mentioned, I can rename the files to add the "txt" extension
and the problem disappears.
But I am getting nowhere with this issue. I'll just leave the workaround
of renaming to txt in place.
The Help staff of your web hosting service are idiots.
The permissions on the relevant directories are 755 as they should be.
The permissions on the files are 644 as they should be.
What about owner and group?
Then you should be adding a line like:
AddType text/tcl cs
to .htaccess
Could it be SElinux stopping mod_tcl from accessing the files ...
Do you want to interpret the tcl files, or merely display them?
Could it be SElinux stopping mod_tcl from accessing the files, maybe you need to run
chcon -R -t httpd_sys_content_t /your/web/content/folder
to allow it?
On Thu, 5 Mar 2026 14:56:36 -0000 (UTC), Robert Heller wrote:
"ERROR 403: Forbidden." more correctly means that the files are not
"readable" by the httpd process.
No. It means the web client is not allowed access. Whether it’s due to server-side filesystem permissions, or just that the web server is
configured not to allow access to that user, is not a distinction
visible to that user. Nor should it be.
On Thu, 5 Mar 2026 21:04:53 -0000 (UTC), Robert Heller wrote:
The Help staff of your web hosting service are idiots.
I could get better help if I were to pay for the premium service
but this problem is not critical.
The permissions on the relevant directories are 755 as they should be.
The permissions on the files are 644 as they should be.
What about owner and group?
The owner and group of every file on the website, and not just the .cs files, are "root."OK, there is something "weird" going on. Do you have the site config files? (The file with <VirtualHost *:443>
FWIW, you can use the following wget commands to access the .cs files and
the .cs.txt files. Both files are in the same directory with the same permissions:
wget http://lapiet.info/mathphys/diffgeo/diffgeo1/geomview/monkey_Saddle-parabola-curve.cs
wget http://lapiet.info/mathphys/diffgeo/diffgeo1/geomview/monkey_Saddle-parabola-curve.cs.txt
The first command will report 403 and the second will download the file
with no problem.
The files are identical except for the file name extensions.
Then you should be adding a line like:
AddType text/tcl cs
to .htaccess
I've tried:AddType text/x-tcl cs
AddType application/x-tcl cs
AddType text/x-script.tcl cs
Neither work.
I suspect that the Apache server at the web host is not configured
properly,
On Thu, 5 Mar 2026 21:09:09 +0000, Andy Burns wrote:
Do you want to interpret the tcl files, or merely display them?
They are text files. The web browser should display them with the
option of downloading.
I have several C program files that are also linked within my web
pages. These files are displayed when the visitor clicks on the
links, but the user can also choose to download.
Could it be SElinux stopping mod_tcl from accessing the files, maybe you need to run
chcon -R -t httpd_sys_content_t /your/web/content/folder
to allow it?
This is a web hosting service. I only have access to my website
files, server logs, and a very limited other set of files.
I could not make that kind of change.
I thought that this issue would have an easy solution but it
seems that it may require a lot of debugging and I don't know
if it would be worth it.
wgethttp://lapiet.info/mathphys/diffgeo/diffgeo1/geomview/monkey_Saddle-parabola-curve.cs
wgethttp://lapiet.info/mathphys/diffgeo/diffgeo1/geomview/monkey_Saddle-parabola-curve.cs.txt
The first command will report 403 and the second will download the file
with no problem.
OK, there is something "weird" going on.
Do you have the site config files?
(The file with <VirtualHost *:443>
ServerName lapiet.info
..
</VirtualHost>
Partitularly, the <Directory ...> ... </Directory> lines. There is some fishy
with the various options and settings there,
AddType text/x-tcl cs
*OR*
AddType text/plain cs
Typically .cs files are csharp files O i assume you're doing some kind
of programming or wanting to show programming files, but not sure.
What is it you're actually trying to accomplish? Simply display source
code in your website?
Given its you, I simply do not believe you
But I have given up trying to solve this.
Thanks to all for the advice.
On Fri, 6 Mar 2026 14:11:07 -0000 (UTC), fregas wrote:
Typically .cs files are csharp files O i assume you're doing some kind
of programming or wanting to show programming files, but not sure.
What is it you're actually trying to accomplish? Simply display source code in your website?
These cs files are for the visitor to download to his machine and then
load into his local software so as to duplicate the results that are
shown on the website.
But I have given up trying to solve this.
Thanks to all for the advice.
I've poking through my various Apache2 config files and found something interesting:
In /etc/apache2/mods-enabled/mime.conf there is this line:
AddLanguage cs .cz .cs
This suggests that files ending in .cs might be considered to be in Czech. This might be causing problems. Like maybe the Czech language module is not installed or inaccessable or something like that and the 403 error relates to that.
Try adding
RemoveLanguage cs
to ,htaccess
Is there some reason these files are using the .cs extension and not .tcl?
At Thu, 05 Mar 2026 22:19:25 +0000 Farley Flud <[email protected]> wrote:
On Thu, 5 Mar 2026 21:09:09 +0000, Andy Burns wrote:
Do you want to interpret the tcl files, or merely display them?
They are text files. The web browser should display them with the
option of downloading.
I have several C program files that are also linked within my web
pages. These files are displayed when the visitor clicks on the
links, but the user can also choose to download.
Could it be SElinux stopping mod_tcl from accessing the files, maybe you need to run
chcon -R -t httpd_sys_content_t /your/web/content/folder
to allow it?
This is a web hosting service. I only have access to my website
files, server logs, and a very limited other set of files.
I could not make that kind of change.
I thought that this issue would have an easy solution but it
seems that it may require a lot of debugging and I don't know
if it would be worth it.
----
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services http://www.deepsoft.com/ -- Linux Administration Services [email protected] -- Webhosting Services
| Sysop: | DaiTengu |
|---|---|
| Location: | Appleton, WI |
| Users: | 1,101 |
| Nodes: | 10 (0 / 10) |
| Uptime: | 492417:34:55 |
| Calls: | 14,115 |
| Files: | 186,270 |
| D/L today: |
3,093 files (953M bytes) |
| Messages: | 2,497,669 |