Can't edit files on server (works fine on local)

Hi,

In the panel, when I click on a file from the sidebar (or from the files page), I got redirected to a page containing a Json string (CF screenshot).

This is only happening on the server, I can properly edit files on localhost.

I tried to turn on debug mode, but it doesn’t throw any error.

Any ideas?

Thanks!

Please check your server error logs (if available) and also your console in browser dev tools and the network tab.

I don’t have access to the server error logs unfortunately.

The console briefly shows this waring before redirecting to the json file:

Ressource interpreted as Document but transferred with MIME type application/json

And I don’t see any error in the Network tab.

Thanks!

Kind of sounds like you have a misconfigured server that is not properly sending certain file types due to incorrect or unset MIME types.

Try adding this to the .htaccess file

# ######################################################################
# # MEDIA TYPES AND CHARACTER ENCODINGS                                #
# ######################################################################

# ----------------------------------------------------------------------
# | Media types                                                        |
# ----------------------------------------------------------------------

# Serve resources with the proper media types (f.k.a. MIME types).
#
# https://www.iana.org/assignments/media-types/media-types.xhtml
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype

<IfModule mod_mime.c>

  # Data interchange

    AddType application/atom+xml                        atom
    AddType application/json                            json map topojson
    AddType application/ld+json                         jsonld
    AddType application/rss+xml                         rss
    AddType application/vnd.geo+json                    geojson
    AddType application/xml                             rdf xml


  # JavaScript

    # Normalize to standard type.
    # https://tools.ietf.org/html/rfc4329#section-7.2

    AddType application/javascript                      js


  # Manifest files

    AddType application/manifest+json                   webmanifest
    AddType application/x-web-app-manifest+json         webapp
    AddType text/cache-manifest                         appcache


  # Media files

    AddType audio/mp4                                   f4a f4b m4a
    AddType audio/ogg                                   oga ogg opus
    AddType image/bmp                                   bmp
    AddType image/svg+xml                               svg svgz
    AddType image/webp                                  webp
    AddType video/mp4                                   f4v f4p m4v mp4
    AddType video/ogg                                   ogv
    AddType video/webm                                  webm
    AddType video/x-flv                                 flv

    # Serving `.ico` image files with a different media type
    # prevents Internet Explorer from displaying then as images:
    # https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee

    AddType image/x-icon                                cur ico


  # Web fonts

    AddType application/font-woff                       woff
    AddType application/font-woff2                      woff2
    AddType application/vnd.ms-fontobject               eot

    # Browsers usually ignore the font media types and simply sniff
    # the bytes to figure out the font type.
    # https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
    #
    # However, Blink and WebKit based browsers will show a warning
    # in the console if the following font types are served with any
    # other media types.

    AddType application/x-font-ttf                      ttc ttf
    AddType font/opentype                               otf


  # Other

    AddType application/octet-stream                    safariextz
    AddType application/x-bb-appworld                   bbaw
    AddType application/x-chrome-extension              crx
    AddType application/x-opera-extension               oex
    AddType application/x-xpinstall                     xpi
    AddType text/vcard                                  vcard vcf
    AddType text/vnd.rim.location.xloc                  xloc
    AddType text/vtt                                    vtt
    AddType text/x-component                            htc

</IfModule>

Hey,

Thanks for the reply, I added the MIME types definitions part to the .htaccess but it doesnt solve the problem

The server is a basic godady server.

Here is the full htaccess file:

# Kirby .htaccess

# rewrite rules
<IfModule mod_rewrite.c>

# enable awesome urls. i.e.:
# http://yourdomain.com/about-us/team
RewriteEngine on

# make sure to set the RewriteBase correctly
# if you are running the site in a subfolder.
# Otherwise links or the entire site will break.
#
# If your homepage is http://yourdomain.com/mysite
# Set the RewriteBase to:
#
# RewriteBase /mysite

# In some enviroments it's necessary to
# set the RewriteBase to:
#
# RewriteBase /

# block text files in the content folder from being accessed directly
RewriteRule ^content/(.*)\.(txt|md|mdown)$ index.php [L]

# block all files in the site folder from being accessed directly
# except for requests to plugin assets files
#RewriteRule ^assets/plugins/([a-zA-Z0-9\.\-_%=]+)/(.*)$ site/plugins/$1/assets/$2 [L,N]
#RewriteCond $1 !^plugins/[a-zA-Z0-9\.\-_%=]+/assets/.*
RewriteRule ^site/(.*) index.php [L]

# block direct access to kirby and the panel sources
RewriteRule ^(kirby|panel\/app|panel\/tests)/(.*) index.php [L]

# make panel links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^panel/(.*) panel/index.php [L]

# make site links work
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) index.php [L]

</IfModule>

# Additional recommended values
# Remove comments for those you want to use.
#
# AddDefaultCharset UTF-8
#
# php_flag short_open_tag on

# ######################################################################
# # MEDIA TYPES AND CHARACTER ENCODINGS                                #
# ######################################################################

# ----------------------------------------------------------------------
# | Media types                                                        |
# ----------------------------------------------------------------------

# Serve resources with the proper media types (f.k.a. MIME types).
#
# https://www.iana.org/assignments/media-types/media-types.xhtml
# https://httpd.apache.org/docs/current/mod/mod_mime.html#addtype

<IfModule mod_mime.c>

  # Data interchange

    AddType application/atom+xml                        atom
    AddType application/json                            json map topojson
    AddType application/ld+json                         jsonld
    AddType application/rss+xml                         rss
    AddType application/vnd.geo+json                    geojson
    AddType application/xml                             rdf xml


  # JavaScript

    # Normalize to standard type.
    # https://tools.ietf.org/html/rfc4329#section-7.2

    AddType application/javascript                      js


  # Manifest files

    AddType application/manifest+json                   webmanifest
    AddType application/x-web-app-manifest+json         webapp
    AddType text/cache-manifest                         appcache


  # Media files

    AddType audio/mp4                                   f4a f4b m4a
    AddType audio/ogg                                   oga ogg opus
    AddType image/bmp                                   bmp
    AddType image/svg+xml                               svg svgz
    AddType image/webp                                  webp
    AddType video/mp4                                   f4v f4p m4v mp4
    AddType video/ogg                                   ogv
    AddType video/webm                                  webm
    AddType video/x-flv                                 flv

    # Serving `.ico` image files with a different media type
    # prevents Internet Explorer from displaying then as images:
    # https://github.com/h5bp/html5-boilerplate/commit/37b5fec090d00f38de64b591bcddcb205aadf8ee

    AddType image/x-icon                                cur ico


  # Web fonts

    AddType application/font-woff                       woff
    AddType application/font-woff2                      woff2
    AddType application/vnd.ms-fontobject               eot

    # Browsers usually ignore the font media types and simply sniff
    # the bytes to figure out the font type.
    # https://mimesniff.spec.whatwg.org/#matching-a-font-type-pattern
    #
    # However, Blink and WebKit based browsers will show a warning
    # in the console if the following font types are served with any
    # other media types.

    AddType application/x-font-ttf                      ttc ttf
    AddType font/opentype                               otf


  # Other

    AddType application/octet-stream                    safariextz
    AddType application/x-bb-appworld                   bbaw
    AddType application/x-chrome-extension              crx
    AddType application/x-opera-extension               oex
    AddType application/x-xpinstall                     xpi
    AddType text/vcard                                  vcard vcf
    AddType text/vnd.rim.location.xloc                  xloc
    AddType text/vtt                                    vtt
    AddType text/x-component                            htc

</IfModule>

Hmmm. Are you sure that the files were transferred to the server correctly? Try re uploading. It might be that one of the files is corrupt and is being improperly served.

Also, assuming that you are using Chrome - do you get the error with other browsers? Try Opera or Firefox. Chrome has had a couple of really obscure bugs lately (such has not having a proper favicon on the site can prevent sessions from working properly. Thats like your car blowing up if you don’t have any bumper stickers.)

1 Like

I have the same issue on Safari / FF.
Hum, there are a lot of files on this site, and none of them can be edited (from any pages).

Should I try to re-upload the whole site from scratch?

I would to be sure the files are ok. Heres a tip: theres probably a file manager in the Godaddy account somewhere that will show you the files on the server. Zip archive the website and transfer it to your webroot with ftp. Then use the godaddy control panel to unzip it on the server. This is much faster then sending all the individual files by FTP. (You should never use FTP anyway because its totally insecure. Use SFTP instead.)

If this does not help, please try to upload a fresh starterkit instead of your project and check if the error persists.

What is your server environment, OS, PHP version etc.?

So I tried to re-deploy from scratch the whole site using beanstalk (SFTP), and it didn’t solve the problem.
Then, I uploaded a basic staterkit like @texnixe said, but still the same issue.

So I think it’s related to the server configuration.

I looked into the GoDady admin, and the client apparently got a “wordpress ready” plan.
That might be related, even though I don’t see why only the “edit file” pages don’t work.

PHP version is 5.6.32, can’t find any other info in the GoDady admin (and can’t switch to a more basic plan).

I also try to to uncomment RewriteBase / in .htaccess just to be sure, but it didn’t do anything.

I guess my only option is to ask my client to get a new hosting plan and cancel the goDady one :confused:

I’d contact their support, maybe they have an idea or can check error logs. And if they can’t help, then one more reason to change host. Don’t see why a Wordpress ready plan shouldn’t work with Kirby.

If you do switch away, I would suggest getting a shared hosting account with Media Temple (be aware they are owned by GoDaddy) or if your in the UK, I can highly recommend Krystal hosting.

Most Wordpress styled hosting is optimised to work with a database, but if a host claims it is Wordpress compatable, then it is more than sufficient to run Kirby. However, your probably paying a little more then you need to because you most likely will not use the database.