Welcome Guest, Not a member yet? Register   Sign In
help - debugging route issues?
#1

I'm working on a CI project that I moved to a new server.  Everything worked fine on the existing server (our production server, I'm trying to make a dev server)  However, I can't seem to get the routes to work on the new server.

I've done repeated searches here and on the web and I haven't been able to find a solution.  

I've changed the base_url to the new url (beta.example.com/project vs www.example.com/project) in config.php and I've got all the routes set up as they were on the previous machine.

All I'm able to do is have the main page load (C_main / V_main).  For every other page I get a 404, including the main page if I specify it in the url (beta.example.com/project/main vs beta.example.com/project)

The strange thing is that the main page loads if there's text in the $route['default_controller'] value, though it doesn't seem to require it to be the controller name.

I'm using CI4 on apache ubuntu server.  The CI app is a part of a wordpress site, in it's own subfolder called application/ 

Thank you all, Mel

config.php sets these variables

$config['base_url'] = 'https://beta.example.com/project/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
$config['url_suffix'] = '';
$config['language'] = 'english';
$config['charset'] = 'UTF-8';
$config['enable_hooks'] = FALSE;
$config['subclass_prefix'] = 'BS_';
$config['composer_autoload'] = FALSE;
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
$config['enable_query_strings'] = FALSE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
$config['directory_trigger'] = 'd';
$config['allow_get_array'] = TRUE;
$config['log_threshold'] = 4;
$config['log_path'] = '';
$config['log_file_extension'] = '';
$config['log_file_permissions'] = 0644;
$config['log_date_format'] = 'Y-m-d H:iConfused';
$config['error_views_path'] = '';
$config['cache_path'] = '';
$config['cache_query_string'] = FALSE;
$config['encryption_key'] = '';
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
$config['cookie_prefix'] = '';
$config['cookie_domain'] = '';
$config['cookie_path'] = '/';
$config['cookie_secure'] = TRUE;
$config['cookie_httponly'] = FALSE;
$config['standardize_newlines'] = FALSE;
$config['global_xss_filtering'] = FALSE;
$config['csrf_protection'] = FALSE;
$config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE;
$config['csrf_exclude_uris'] = array();
$config['compress_output'] = FALSE;
$config['time_reference'] = 'local';
$config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';

Here's the relevant section of routes.php:
$route['main'] = 'C_main';
$route['apply'] = 'C_apply';

$route['default_controller'] = 'r';  // note that even with the meaningless value of "r", the main page loads.  If the value is empty, it errors out.
$route['404_override'] = 'C_main';
$route['translate_uri_dashes'] = FALSE;


So, is there some way to actually walk through or otherwise debug routing?  I've got CI logs on full but they don't show anything after the main page is loaded - there's no evidence in the log that there was even an attempt to load the following page, called "apply"  The info below is from the apache2 access log (the error log doesn't have any messages in this time frame)


104.128.237.214 - - [19/Jan/2023:22:44:12 -0500] "GET /project/ HTTP/1.1" 500 6672 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36>
104.128.237.214 - - [19/Jan/2023:22:44:12 -0500] "GET /project/ HTTP/1.1" 500 1998 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36>
104.128.237.214 - - [19/Jan/2023:22:44:12 -0500] "GET /favicon.ico HTTP/1.1" 302 1172 "https://beta.example.com/project/" "Mozilla/5.0 (W>
104.128.237.214 - - [19/Jan/2023:22:44:22 -0500] "GET /project/ HTTP/1.1" 200 7522 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36>
104.128.237.214 - - [19/Jan/2023:22:44:42 -0500] "-" 408 579 "-" "-"
104.128.237.214 - - [19/Jan/2023:22:45:46 -0500] "GET /project/main HTTP/1.1" 404 23508 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/5>
104.128.237.214 - - [19/Jan/2023:22:45:47 -0500] "GET /wp-content/cache/autoptimize/js/autoptimize_2c767c0106b1f7a2d4a72ac555cd7b64.js HTTP/1.1" 200 16>
104.128.237.214 - - [19/Jan/2023:22:45:47 -0500] "GET /wp-content/cache/autoptimize/css/autoptimize_a39a5a2a68958caed3b6c7bb254974ec.css HTTP/1.1" 200 >
104.128.237.214 - - [19/Jan/2023:22:45:48 -0500] "GET /wp-includes/js/wp-emoji-release.min.js?ver=5.6.10 HTTP/1.1" 200 5079 "https://beta.example>
104.128.237.214 - - [19/Jan/2023:22:45:50 -0500] "GET /project/ HTTP/1.1" 200 6791 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36>
104.130.140.134 - - [19/Jan/2023:22:51:05 -0500] "POST /wp-cron.php?doing_wp_cron=1674186665.3649849891662597656250 HTTP/1.1" 200 5534 "https://beta.bl>
104.128.237.214 - - [19/Jan/2023:22:51:05 -0500] "POST /project/apply HTTP/1.1" 404 28158 "https://beta.example.com/project/" "Mozilla>
104.128.237.214 - - [19/Jan/2023:22:51:25 -0500] "-" 408 5253 "-" "-"
104.128.237.214 - - [19/Jan/2023:22:51:34 -0500] "GET /project/ HTTP/1.1" 200 7522 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36>
104.128.237.214 - - [19/Jan/2023:22:51:42 -0500] "POST /project/apply HTTP/1.1" 404 23484 "https://beta.example.com/project/" "Mozilla>

There are .htaccess files at the site level (beta.example.com), at the project folder level (/project), and at in the CI application folder.

site level .htaccess
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

project level .htaccess
#DirectoryIndex index.php
    RewriteEngine On
    RewriteBase /project/

# Protect application and system files from being viewed when the index.php is missing
RewriteCond $1 ^(application|system|private|logs)

# Rewrite to index.php/access_denied/URL
RewriteRule ^(.*)$ index.php/access_denied/$1 [PT,L]

# Allow these directories and files to be displayed directly:
RewriteCond $1 ^(index\.php|robots\.txt|favicon\.ico|public|assets|css|js|images|fonts|mfiles|documents|captcha|jqwidget)

# No rewriting
RewriteRule ^(.*)$ - [PT,L]

RewriteRule ^(.*)$ /project/index.php/$1 [L]

CI application level .htaccess
<IfModule authz_core_module>
    Require all denied
</IfModule>
<IfModule !authz_core_module>
    Deny from all
</IfModule>
Reply
#2

(This post was last modified: 01-21-2023, 11:59 AM by captain-sensible. Edit Reason: elaborated in poor English i agree )

This seems a bit incongruous
Code:
site level .htaccess
# BEGIN WordPress
........


So does ,lines which say" wp-content " . I don't think i have come across ..so far "wp-content" in CodeIgniter



Can you clarify why you are using a .htaccess which it seems you got from Wordpress ?

i see your on ubuntu; "i'm on Arch by the way" ( you will get the in joke i think) i have my web devs running , in apache web server on sub domain basis on my laptop and live web , also on sub domain basis . I have never had to touch ever .htacess files. before Arch i ran slackare so obviously i am very lazy.
I use 127.0.0.x to bring up landing pages of devs . I do that using /etc/hosts eg


Code:
// abstract from my laptop /etc/hosts
127.0.0.1  localhost
::1        localhost
127.0.1.1 darkstar.localdomain darkstar
127.0.0.5  kursaal.org
127.0.0.6 ads.com
127.0.0.7 kursaal2.org

In terms of getting system to look for requests public i use virtual host, to point to public
On live i just used cPanel "add on domain" then edit document root for subdmain to point to public of web dev in sub domain of main hosting web root.


The main difference between localhost and live , is that for me secure socket is a pain on local so in base url is use kursaal2.org :
Code:
public $baseURL = 'http://127.0.0.7/';

On live , you have to use secure socket https//

I go about it starting with a blank dev. I put index.html into public and then from cPanel i use "lets encrypt" . I then change baseUrl to https://domain dot something . I first make sure https works. Then i start populating all the code from CI4 .
CMS CI4     I use Arch Linux by the way 

Reply
#3

Thank you so much for the reply.  I'm sure I included way too much info.  I wasn't able to get this working, but I did manage to set up a testing directory on yet another machine where it works.  Must have been a configuration issue that was outside the realm of CI.
Thank you again, Mel
Reply




Theme © iAndrew 2016 - Forum software by © MyBB