Cms post page giving error

Hi @dan @ben

I have an error on my post page with cms in Elements. The website is https://www.audio.lionofjudahmin.com

The archives page is set up for cms and then the individual post page. The archive page works fine, but when I click on an individual post I get the following:

var RWElements={};

RWElements.rwC7063805_9D3C_4A35_9B49_90ED20B7264F = {};
RWElements.rwC7063805_9D3C_4A35_9B49_90ED20B7264F = (function(componentId) {

console.log(Running JS for element with id: )

return componentId;})(RWElements.rwC7063805_9D3C_4A35_9B49_90ED20B7264F);

In preview more I can navigate the site especially the Archives page and the individual post page no problem, but live I get the above. Any ideas?

The screenshot is of the individual post page in preview mode.

Does any of the CMS work when online? If not I’d guess the PHP version might not be up-to-date…

However, if you’re PHP is all up-to-date (v8.x) and parts of the CMS are working online, I’d suggest sending us your Elements project so we can take a look and see if we can re-create the issue on our servers.

Hi @dan

PHP version is 8.2 on server (Hostgator).

That is the thing The archives page works but when you click on the individual article to get to the post then the page opens to the script above.

How do I best send th project to you? The project is on the cloud.

My guess is that you have the “Item Template” setting on the Collection set incorrectly — could you check that the Item Template is linked to the correct page?

If it is correctly linked, could you send us the project via Elements Cloud :slight_smile:

Thanks @ben ,

the page is correctly linked. I have uploaded the project to Elements Cloud.

You will see that there is a button on the individual post page that Elements bot helped with coding to be able to download an audio file. Perhaps there is a glitch there some where.

you need to share the project link with us — click the link icon next to the uploaded project, that will copy the URL to the project, then paste it in here :slight_smile:

Ok can I send it by email? I sent the link on the email chat.

Hi Ben,

Here is the link

Kind Regards,
GĂĽnther Schenk

Phone:
International dialing code: +264
T: (0)61 240 368

M: (0)81 243 2558

E-mail: clientcare@fgonline.net

Web: www.fgonline.net

"This information is intended only for the person or entity to which it is addressed and may contain private, confidential, proprietary and/or privileged material and may be the subject to confidentiality agreements. Any review, retransmission, dissemination, or any other use of or taking of any action in reliance upon this information, by persons or entities other than the intended recipient, is prohibited.

If you received this in error, please contact the sender and delete the material from all storage media. The company is neither liable for proper, complete transmission of the information contained in this communication, any delay in its receipt or that the mail is “virus-free”.

GO GREEN and help save paper by printing only the necessary emails / documents.

Hi @Lion

I’ve take another look at this, and I believe this is a server configuration issue. Who are you hosting your site with?

Possible Causes

  1. MIME type or file handler misconfiguration
  • Apache might be incorrectly treating the index.php in that directory as a .js file due to .htaccess rules or server-level MIME type overrides.
  • This often happens if AddType or AddHandler directives are used incorrectly in .htaccess.
  1. Static file is overriding the PHP processing
  • If there is a file like index.js or even index.php with JavaScript content in the /archives/post/ folder, Apache might be serving that file as is, especially if PHP is disabled or misconfigured for that directory.
  1. Missing DirectoryIndex rule
  • Apache doesn’t know which file to serve by default in /archives/post/, so it might grab the first available or misconfigured one.
  • The correct behavior is to use: DirectoryIndex index.php
  1. Broken rewrite rules
  • A bad RewriteRule might be rewriting the pretty URL (/archives/post/) in a way that points to a JS file or exposes its contents.

I would first check the above issues with your hosting company, and if they are unable to fix this for you, then it seems most likely to me that you could fix this yourself with an .htaccess.

Create a file inside the archives/post folder and call it .htaccess. Place the following code in that file:

# Set the default file to index.php
DirectoryIndex index.php

# Rewrite to index.php if file/folder does not exist
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [L]

Let us know how you get on and if you need any more support :slight_smile:

Thanks @Ben.

Appreciate the help. I will get going on this right away. I am hosting with Hostgator.

Kind Regards,
GĂĽnther Schenk

@Ben

Thanks of the help. I found it easier to add the htaccess file the way you said and that did the trick.

This is my first time working with cms really. I will see when I have some extra time to go on a live chat with HG to see if they can fix this.

But essentially I could just add this htaccess file to future projects if the same issue pops up? Or would it be more advisable to fix it server side for the domains that would need cms in the future?

Thanks again for the help. greatly appreciated and also keep up the great work with Elements - Super great working with it.

2 Likes

you certainly can use the same htaccess rules if you run in to this issue again, however, I would recommend fixing it server side.

The code URL that didn’t work on your server is nothing out of the ordinary, it really should “just work” on any shared hosting!

1 Like

@ben I have a similar issue with pages that use custom PHP on my site. i get the following error from my host:

var RWElements={};

RWElements.rw4416938D_5FB7_4564_A7DF_1FC9D4A50F4A = {};
RWElements.rw4416938D_5FB7_4564_A7DF_1FC9D4A50F4A = (function(componentId) {

console.log(Running JS for element with id: )

return componentId;})(RWElements.rw4416938D_5FB7_4564_A7DF_1FC9D4A50F4A);

Would this .htaccess code work in my case too?

https://frithpercussion.com/newsite/deathmatch/rudimental_deathmatch/junior_level/

it looks like the same issue, so yes, I would give the htaccess a try on your server :slight_smile:

1 Like