• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
The requested URL was not found on this server.

#1
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!
Reply

#2
Check your base_url in the config file, it should match your vhost.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply

#3
(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>
Reply

#4
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
Reply

#5
(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/';
Reply

#6
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;
download and make your system directory strict
Reply

#7
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!!!
Reply

#8
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?
Reply

#9
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.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.