skip to Main Content

Struggling. Help!

In index.php:

require "cachedPages/home.html";

If I visit: https://websiteaddress.org/index.php then it works fine.

If I visit: https://websiteaddress.org then I get an internal server error.

I guess it’s a .htaccess thing. All I have in there is some cpanel php72 code and:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
DirectoryIndex index.php

It seems there’s some difference between how index.php is called if you call it directly as opposed to .htaccess calling it for you?!?

Any ideas?

Thanks in advance.

2

Answers


  1. Chosen as BEST ANSWER

    Well, I've managed to sort the problem, but it's a pretty weird situation that no-one else will probably ever experience. Here goes...

    If the user lands at: https://websiteaddress.org rather than https://websiteaddress.org/index.php and that page (php) requires another page, which has images that are embedded as URIs rather than linked src files.

    Then, the first URI causes a server error.

    If I replace the

    img src='data:image/jpeg;base64,/998a9g98ahg...etc' 
    

    with

    img src='path/to/file.jpg' 
    

    on the first instance of a jpg then it all works fine. All the later URIs are fine, it's just the first instance!

    It all works now, with this workaround; and the situation is so unique and bizarre that I doubt this thread will be of use to anyone else. In fact it's so edge-case that I can't be bothered investigating it any further myself.


  2. If you don’t have one of the following options in your .htaccess then Apache won’t know which file to default back to:

    DirectoryIndex index.php
    FallBackResource /index.php
    

    Also I’d recommend installing mod_rewrite as well. It’s handy for other reasons.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search