CodeIgniter Forums
The requested URL was not found on this server. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Development (https://forum.codeigniter.com/forum-6.html)
+--- Forum: Issues (https://forum.codeigniter.com/forum-19.html)
+--- Thread: The requested URL was not found on this server. (/thread-74877.html)



The requested URL was not found on this server. - chrisco - 11-19-2019

Hello,
I decided to make a local copy of my website so I build a web server with apache/MariaDB/php73. Also, create a virtual host for my site. The problem is that it only displays my home page and for every link that I click I get an error similar to this one:
The requested URL /за-мен was not found on this server.

Nothing is changed from the public copy of the site and everything is ok there.

Any help will be appreciated!


RE: The requested URL was not found on this server. - InsiteFX - 11-20-2019

Check your base_url in the config file, it should match your vhost.


RE: The requested URL was not found on this server. - chrisco - 11-20-2019

(11-20-2019, 04:44 AM)InsiteFX Wrote: Check your base_url in the config file, it should match your vhost.

here is my base_url:

Code:
$config['base_url'] = '';

and my vhost conf file:

Code:
<VirtualHost *:8080>
    ServerName www.example.com
    ServerAlias examle.com
    DocumentRoot /var/www/example.com/public_html/www
    ErrorLog /var/www/example.com/error.log
    CustomLog /var/www/example.com/requests.log combined
</VirtualHost>



RE: The requested URL was not found on this server. - demyr - 11-20-2019

Have you checked your htaccess file yet?

Code:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Codeigniter Documentation page about htaccess


RE: The requested URL was not found on this server. - dave friend - 11-20-2019

(11-20-2019, 08:27 AM)chrisco Wrote: here is my base_url:

Code:
$config['base_url'] = '';

and my vhost conf file:

Code:
<VirtualHost *:8080>
    ServerName www.example.com
    ServerAlias examle.com
    DocumentRoot /var/www/example.com/public_html/www
    ErrorLog /var/www/example.com/error.log
    CustomLog /var/www/example.com/requests.log combined
</VirtualHost>

Base on the VirtualHost the base_url should be

Code:
$config['base_url'] = 'http://example.com/';

Unless you are using SSL, in which case it should be


Code:
$config['base_url'] = 'https://example.com/';



RE: The requested URL was not found on this server. - John_Betong - 11-20-2019

Try this:
# https://forum.codeigniter.com/thread-74649.html
# File: index.php
if( TRUE || DEFINED('AUTOMATIC_URL_DETECTION') ) :
$tmp = (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS'])
&&
('on' == $_SERVER['HTTPS'])
? "https://"
: "http://") .$_SERVER['HTTP_HOST']
;
$tmp .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);
define('BASEURL', $tmp);
endif;

# file: Config/App.php -> public $baseURL = BASEURL;


RE: The requested URL was not found on this server. - chrisco - 11-25-2019

Solved!

Thanks to everyone for the help. I managed to fix my problem with generating SSL keys and include them in my vhost configuration like this:
Code:
<VirtualHost *:443>
    DocumentRoot "${SRVROOT}/htdocs/example.com/www/"
    ServerName example.com

    SSLEngine on
    SSLCertificateFile "conf/ca.crt"
    SSLCertificateKeyFile "conf/ca.pem"
    <Directory "${SRVROOT}/htdocs/example.com/www/">
        Options All
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

also, I get an error for "Session: Configured save path '' is not a directory, doesn't exist or cannot be created.", that error is because of difference in OS. Locally I'm using Windows, so the solution for that issue is to change the sess_save_path option in config.php file. 
Code:
$config['sess_save_path'] = sys_get_temp_dir();

After that, I get another error ".htaccess: Invalid command 'Order', perhaps misspelled or defined by a module not included in the server". That error was because of the difference in Apache versions. The solution is to modify .htaccess file and replace this:
Order Deny,Allow
Deny from All
with:
Require all denied

But now I have another issue which exists in both my local site and my public one on the hosting server. The site is multi-language and when I click to switch on the English version I get Error 404 Page Not Found and I don't see something helpful in logs. Any help will be appreciated!!!


RE: The requested URL was not found on this server. - chrisco - 11-26-2019

Ok, maybe I have some problems with caching. This is what I get Expires: Thu, 19 Nov 1981 08:52:00 GMT and it gives me 404 Page Not Found. Any ideas on how to fix this?


RE: The requested URL was not found on this server. - chrisco - 11-27-2019

Solved!

The reason to get error 404 pages not found and not to see any helpful errors in logs is that the problem was in my database. There were a lot of missing records for my English pages. I don't know how these records were deleted, but I have a backup of my database and all is good now.

Thanks again to all of you that trying to help me.