Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

SOLVED Can I set a default MIME type

Discussion in 'General Discussion' started by icaravans, Feb 10, 2018.

  1. icaravans

    icaravans Registered

    Joined:
    Feb 10, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    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
     
  2. rpvw

    rpvw Well-Known Member

    Joined:
    Jul 18, 2013
    Messages:
    906
    Likes Received:
    347
    Trophy Points:
    113
    Location:
    Spain
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. icaravans

    icaravans Registered

    Joined:
    Feb 10, 2018
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Lincs
    cPanel Access Level:
    Website Owner
    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?
     
  4. 24x7server

    24x7server Well-Known Member

    Joined:
    Apr 17, 2013
    Messages:
    1,888
    Likes Received:
    90
    Trophy Points:
    78
    Location:
    India
    cPanel Access Level:
    Root Administrator
    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..
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,197
    Likes Received:
    1,936
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    I'm glad to see this helped. I've marked this thread as solved.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice