Welcome Guest, Not a member yet? Register   Sign In
codeigniter 3.1.9 with apache and php 7.2 - routing/redirect issues with sym link
#11

(This post was last modified: 07-06-2018, 12:07 AM by BBT.)

(07-05-2018, 11:24 PM)jreklund Wrote: Hi again, those aren't sub-domains. These are:
test1.example.com
test2.example.com
example.com
example.net

So in your case you really should only have:
$config['base_url'] = 'https://example.com';

Try changing the order of the route.php
PHP Code:
$route['test1/select-product'] = "home/select-product";
$route['test2/select-product'] = "home/select-product";
$route['select-product'] = "home/select-product"

If you view the source of the <form> you are submitting, what actual URL have you got?
<form src="https://example.com/test1">...

How do you redirect the user to /test1/select-product?

Activate the debug mode.
/application/config/config.php
$config['log_threshold'] = 4;

You should now get logs inside /application/logs/


================================================================

Hi jreklunk,
Thank you again for your quick reply. When I change the "$config['base_url'] = 'https://example.com';" the home page loads but when I click on "continue" to go to the next page get the below error:


An Error Was Encountered

The action you have requested is not allowed.


And the URL addresses changes to https://192.168.1.2/test1/ instead of https://example.com/test1/select-product.

Below error is logged inside application/logs folder after changing log level to "4" in config.php

INFO - 2018-07-06 17:04:53 --> Config Class Initialized

INFO - 2018-07-06 17:04:53 --> Hooks Class Initialized
DEBUG - 2018-07-06 17:04:53 --> UTF-8 Support Enabled
INFO - 2018-07-06 17:04:53 --> Utf8 Class Initialized
INFO - 2018-07-06 17:04:53 --> URI Class Initialized
DEBUG - 2018-07-06 17:04:53 --> No URI present. Default controller set.
INFO - 2018-07-06 17:04:53 --> Router Class Initialized
INFO - 2018-07-06 17:04:53 --> Output Class Initialized
INFO - 2018-07-06 17:04:53 --> Security Class Initialized
DEBUG - 2018-07-06 17:04:53 --> Global POST, GET and COOKIE data sanitized
INFO - 2018-07-06 17:04:53 --> CSRF cookie sent


When I leave "base_url" value empty and browse to https://192.168.1.2/test1
/ everything works as expected.

Not sure why the response on the public URL is changing to private IP?

Hoping to hear from you soon, as you and other community members are the only hope to fix this problem.


Thank you,
Reply
#12

Can you double check how your URL's are generated? Right click and copy hyperlink.
Do they say https://example.com/test1/select-product or https://192.168.1.2/test1/select-product

"The action you have requested is not allowed." are a CSRF error message, try disable it.
$config['csrf_protection'] = FALSE;

Have you tried different browsers? Sometimes the browsers cache redirects you weird.
Reply
#13

(This post was last modified: 07-08-2018, 10:22 PM by BBT.)

Hi jreklunk/Other valuable community members,
Thank you for your response. It's gives me hope that with the help of this community we can fix this problem  Wink.

Steps involved to check the URL
1.First I browse manually to “https://example.com/test1/”.

Please note – https://example.com is the base_url, and all pagination and web-page flow is working fine when I go directly to base_url.

2. I provide the form inputs for the application. URL generated for this form is “https://example.com/test1/”

3. When I press continue the URL address is supposed to change to “https://example.com/test1/select-product” but in this case it goes back to “https://example.com/select-product, and that is the problem I need to overcome.

When I manually enter “https://example.com/test1/select-product” in the browser, web page is loaded correctly as expected.

4. URL’s are generated as https://example.com/test1/ or https://example.com/ not the IP when the $config['base_url']   = 'https://example.com/'.

When I browse using the private IP/local IP by leaving base_url empty, everything is working fine.

Below is web page directory structure and its mapping:

Web root directory structure:

/var/www/html/
├── application
├── assets
├── test1-> /var/www/html/
├── test2-> /var/www/html/
├── index.php
├── system


https://example.com points to /var/www/html
https://example.com/test1 points to /var/www/html/test2
https://example.com/test2 points to /var/www/html/test2

/var/www/html/test1 is symbolic link to /var/www/html
/var/www/html/test2 is symbolic link to /var/www/html

"assets" directory has all the customisation for each pages inside test1 and test2.


I found the below information on the internet:
By default codeigniter 3 you will not be able to have sub folder in your default_route. You need to use a MY_Router.php

Could this be the reason why I am facing this problem? If so , how could I achieve the expected result mentioned above?

Hoping to hear from you soon.

Thank you,
BBT
Reply
#14

(This post was last modified: 07-09-2018, 01:47 AM by jreklund.)

Quote:2. I provide the form inputs for the application. URL generated for this form is “https://example.com/test1/”
Can you provide us with the code that process your <form>. I thought you had static <a> tags.
Reply
#15

HI jreklunk,
I do not have access to the code right now, so will add that later on. In the meantime, I was curious why the same form application process would work using private IP when base_url is set to empty?. I am confused how providing a URL in base_url field would break the working routing flow from before?

Also, Is this statement true "By default codeigniter 3 you will not be able to have sub folder in your default_route. You need to use a MY_Router.php"

Thank you again for your continuous support/response.
Reply
#16

Can't answer that one. If we had that answer, you wouldn't be here; with a problem.

They mean this one:
PHP Code:
$route['default_controller'] = 'welcome'

It can't be:
PHP Code:
$route['default_controller'] = 'subfolder/welcome'
Reply
#17

(This post was last modified: 07-09-2018, 08:00 PM by BBT.)

Hi Jreklunkd,
Below is the related code as found in home.php - the form that is presented on https://example.com/test1/

home.php
PHP Code:
Beginning of the code:
<?=
form_open('' . (isset($_GET['product_id']) ? '?product_id=' $_GET['product_id'] : ''))?>


Towards the end:

PHP Code:
<?=form_hidden(array('product_id' => isset($_GET['product_id']) ? $_GET['product_id'] : '','reseller_id' => $this->reseller->getResellerId()))?>
     <div class="form-actions form-wrapper" id="edit-actions"><?=form_submit(array('name' => 'op''id' => 'edit-submit''class' => 'btn-green form-submit''type' => 'submit''value' => 'Continue'))?></div>
     <?=form_close()?>

Hope the above makes sense.

Could this be related to "session" handling? 

I am totally clueless here, waiting for your response.

====================================

Also, while waiting for response, I have noticed below pattern and mentioning it here just incase that is related to the problem.

I changed config for base_url and index_page as follows:

PHP Code:
$config['base_url'] = 'https://example.com/test1/';
$config['index_page'] = 'index.php'


Now, the image on the first loading page is not displayed with the below error logged in the application/logs file.
  

PHP Code:
ERROR 2018-07-10 12:47:35 --> 404 Page Not FoundAssets/images 


please note, directory name is "assets" not "Assets" and it is in the root application folder.

When I right click on the image and get the address "index.php", it seems to be retaining index.php as follows:
  
https://example.com/test1/index.php/asse...1/logo.png


PHP Code:
My .htaccess file is as follows:

RewriteEngine On
RewriteCond 
$!^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond 
%{REQUEST_FILENAME} !-d
RewriteRule 
^(.*)$ index.php?/$[L,QSA]
Options -Indexes 


When I leave index.php page empty, then the images are loaded correctly and index.php is removed from the image URL. But I face the problem of routing
as reporting in this ticket.

Just wondering why image URL will not be loaded correctly when I configure "$config['index_page'] = 'index.php';"

Cheers,
Reply
#18

I'm sorry but I needed the Controller code. My bad for not specifying it clearer.

You are using site_url instead of base_url on your images. So index.php get's appended, and that's not a folder so your images can't be found.
Reply
#19

Hi all,
I managed to fix this problem by removing the "symbolic links" and creating independent directories. I then had to copy application, assets, system and index.php to test1 and test2 folder, and base_url in test1/config.php and test2/config.php were set as:

test1/config.php ==> base_url= 'https://example.com/test1';
test2/config.php ==> base_url= 'https://example.com/test2';

Change web directory from:

/var/www/html/
├── application
├── assets
├── test1-> /var/www/html/
├── test2-> /var/www/html/
├── index.php
├── system

To:
/var/www/html/
├── application
├── assets
├── test1
├── test2
├── index.php
├── system

Thank you to everyone that responded to me in this forum. We do have a great community here.

Cheers.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB