icaravans

Registered
Feb 10, 2018
2
0
1
Lincs
cPanel Access Level
Website Owner
I am trying to host a site that has no issues on xampp locally but when I upload to my cpanel hosting the pages with no extension are being served up as text/plain via headers. The page's html contains the correct meta tag to tell the browsers that the file is html but they are listening to the response header which is stating it is text/plain.

Is there a way, preferably via htaccess, to force a MIME type for files with no extension, a default MIME type for example.

This is no issue when setting the type for files with any other extension as this can be easily done via htaccess but I am struggling to find a way to do it for files with no extension.

Thanks a lot from a first time poster here, I hope this is the right place for such a question.

Cheers
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
458
113
UK
cPanel Access Level
Root Administrator
Why don't you just add acceptable (and relevant) extensions to the files ? I think you are making things overly difficult for yourself !
OR
You could try adding a DefaultType in your .htaccess if your server is running below Apache 2.4, otherwise you would probably have to use ForceType wrapped in a FilesMatch
OR
You could try to use a rewrite rule in your .htaccess to add the .html extension to any file that doesn't have one.
 

icaravans

Registered
Feb 10, 2018
2
0
1
Lincs
cPanel Access Level
Website Owner
Why don't you just add acceptable (and relevant) extensions to the files ? I think you are making things overly difficult for yourself !
OR
You could try adding a DefaultType in your .htaccess if your server is running below Apache 2.4, otherwise you would probably have to use ForceType wrapped in a FilesMatch
OR
You could try to use a rewrite rule in your .htaccess to add the .html extension to any file that doesn't have one.
Thanks for the input. The issue is with dealing with multiple sites with large amounts of pages without extension that have been working fine on other hosting and are already indexed so changing extension now would be time consuming and could have a negative impact on SEO.

I have tried the ForceType option and it seems to be working good now.

Thanks a lot for the suggestion, ForceType was many hours quicker than changing file types and the linking structure across some large sites.

Out of interest do you know why the default MIME type is plain text when the huge majority of web servers will be serving up html and not plain text?
 

24x7server

Well-Known Member
Apr 17, 2013
1,911
96
78
India
cPanel Access Level
Root Administrator
Twitter
Out of interest do you know why the default MIME type is plain text when the huge majority of web servers will be serving up html and not plain text?
A file is downloaded or it displays codes directly only when the required module is defined wrong in the server configuration or rather a handler issue. Check the apache error logs and paste it here, so everyone here can take a look and advise accordingly..
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,910
2,215
363
I have tried the ForceType option and it seems to be working good now.

Thanks a lot for the suggestion, ForceType was many hours quicker than changing file types and the linking structure across some large sites.
Hello,

I'm glad to see this helped. I've marked this thread as solved.