1

The following code, in index.php, gives the expected routing behaviour when I run it using the built in php web server:

<?php
$request = $_SERVER['REQUEST_URI'];
switch ($request) {
    case '/' :
        echo 'This is the Home Page';
        break;
    case '/about' :
        echo ' This is the About Page';
        break;
    default:
        echo 'Resource not Found (404)';
        break;
}

The same code uploaded to my Ionos Linux web server running Apache does not work: If I access the root directory from a firefox browser (eg http://mywebsites.org.uk/root-directory) I get Resource not Found (404)in the browser. If I append something to the URL (eg http://mywebsites.org.uk/root-directory/about) the browser just gives some page with advertising on which is what you get when there is nothing corresponding to that path on the server). Same happens if you change 'about' for any other word.

I tried with the following .htaccess file in the root directory along with the index.php file:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ index.php [QSA,L]

Now I get the same result with http://mywebsites.org.uk/root-directory. That shows Resource not Found (404) in the browser as before. However, with http://mywebsites.org.uk/root-directory/about or any word substituting 'about' I now get an error message in the browser:

Multiple Choices The document name you requested (/index.php) could not be found on this server. However, we found documents with names similar to the one you requested. Available documents: /index.html (common basename)

When I click on index.html (which is hyperlinked) I find that it is in the directory above the root-directory with the index.php file in it. Ie it is in the mywebsites.org.uk directory. Obviously it is not what I am after.

I also tried replacing the content of the .htaccess file with FallbackResource /index.php. The result was the same as when I had no .htaccess file at all which I described earlier.

I am finding it very difficult to understand my Ionos web server. I do not know if I can change configuration files for Apache or not and I have little understanding of .htaccess files. I have thought of changing to AWS over this issue as the documentation there seems more thorough. However I would prefer not to change if I can sort this issue out. Basically I want to be able to build a PHP router on my Ionos server which runs Apache.,

1 Answer 1

3

You are correct that the built-in PHP web server enables you to use a routing script. However, in environments such as your hosting on Ionos, this function is generally performed by whatever web server is running.

Unfortunately, I'm having trouble finding which web server Ionos offers by scanning their web site. Are you certain that they are running Apache and that they have mod_rewrite and local .htaccess overrides enabled? Any of these could explain why you're having issues there.

From your description of your issues, it also sounds like your web site may not have its document root path configured correctly, or that it is not set up to use index.php as a directory index file (e.g. via the DirectoryIndex Apache configuration setting).

The best I can suggest is contacting Ionos techical support or seeking out any technical documentation they offer to customers. I can't even tell if or what configurations they may allow you to override.

Sign up to request clarification or add additional context in comments.

2 Comments

phpinfo() tells me it is Apache. I cant find answers to the other issues. In the past Ionos technical support did not help me and was expensive. Any suggestions for hosting company with good documentation for Apache servers? I was thinking of trying AWS.
AWS will only provide support for their infrastructure. You'll have full control over your server environment (e.g. EC2 instance) there, but the rest will be up to you. For other potential providers, digitalocean.com and dreamhost.com tend to be the ones I hear about most often.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.