I
I
Issue2021-03-27 03:34:01
PHP
Issue, 2021-03-27 03:34:01

Why does typing SERVER['REQUEST_URI'] result in a 404 error?

The Apache web server is installed on the local machine. There are two domains: localhost and sub.localhost
When navigating through these domain names, everything works fine, index.php opens from /var/www/html/ .
All I have to do is type crm.localhost/something and it results in a 404 error. What's the problem?

.htaccess:

RewriteEngine On  
RewriteBase /

RewriteCond %{SCRIPT_FILENAME} !-f  
RewriteRule ^(.*)$ ./index.php


index.php:
<?php 
  $sub = explode('.', urldecode($_SERVER['HTTP_HOST']))[0];
  if ($sub == 'sub') {
    include 'template/subdomain.php';
  } else {
    include 'template/domain.php';
  }
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vitaly_74, 2021-03-27
@paulenot

strange, but the title is about SERVER['REQUEST_URI'] - but the question is about something else.
In your case, most likely the Apache config is not correctly configured, and the folders in the config itself are not correctly forwarded, can you show the Apache config?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question