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!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    618
    Likes Received:
    192
    Trophy Points:
    43
    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.
     
  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,734
    Likes Received:
    78
    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..
     
  5. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    42,802
    Likes Received:
    1,714
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

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

Share This Page