Jump to content

404 - Page not found, inserts root folder into URL.


edgetas
 Share

Recommended Posts

Hi I am getting an intermittent "404 - Page Not Found" error, it seems to affect all browsers and platforms at times and other times it works fine.


When accessing the store via our domain name - tasgingerbread.com, occasionally navigating the side bar, it will insert /storetgb (the root folder the store is located) into the url.
EG, instead of
https://tasgingerbread.com/original-recipe/christmas.html
it will  use https://tasgingerbread.com/storetgb/original-recipe/christmas.html
resulting in the 404 error.

The location on the server is
https://ontas.net/storetgb/index.php
When the error occurs and you click on "Homepage" in the left menu, it reverts to the ontas URL, then works fine.
(I have changed the 404 error message to direct visitors, but that's not ideal).

Clearing the cache seems to fix it, though only temporarily, even though we've changed nothing in admin.

I'm not sure if it is a problem with my CubeCart configuration or my domain name setup.

I have the Domain pointing at my hosting nameservers, and in cPanel:

Addon Domains

Document Root 

Subdomain

Redirects to

tasgingerbread.com

/public_html/storetgb

tasgingerbread

not redirected

 

Any help or ideas would be appreciated.
Cheers, Tone.

Link to comment
Share on other sites

Please examine the file /includes/global.inc.php.

Are there any $glob array elements making a reference to "ontas.net" or "storetgb".

Also, check the contents of the .htaccess file in CubeCart's root folder.

The 'Home' link and Original Recipe links in the breadcrumbs are correct, but the Homepage link in the Shop by Category ('navigation') list is misdirected, and all the category links are not correct. (The navigation structure is cached. And will get rebuilt and re-cached if the URL used to get to your store changes.)

In the Site Docs box at the bottom, the View Basket link is misdirected.

Link to comment
Share on other sites

Please let us know the exact version of CubeCart you are using.

Looking at CC644, for example, in the file /ini.inc.php, line 100, we see:

$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) :  strtolower($_SERVER['SERVER_NAME']);

So, if the Request Headers has: Host: tasgingerbread.com, then PHP should set $server_name to that value. If, on the other hand, LiteSpeed did not give PHP a proper http_host name, then the $server_name will be what LiteSpeed knows to be what it is really called, the server_name. This is discussed here:

https://www.w3schools.com/Php/php_superglobals_server.asp

In admin, at the bottom of the side Navigation bar, click on PHP Info (may be named differently depending on the version of CubeCart). Scroll to the PHP Variables table and verify the values.

The "View Basket" link in the Site Docs box appears to be a customization. Check how it is coded.

Link to comment
Share on other sites

Contents of /includes/global.inc.php.

<?php
$glob['adminFile'] = 'admin_######.php';
$glob['adminFolder'] = 'admin_######';
$glob['dbdatabase'] = '###edge#_storegb';
$glob['dbhost'] = 'localhost';
$glob['dbpassword'] = '#######';
$glob['dbprefix'] = 'eui_';
$glob['dbusername'] = '###edge#_storegb';
$glob['encoder'] = 'ioncube';
$glob['installed'] = '1';
$glob['install_source'] = 'softaculous';
$glob['cache'] = 'file';
?>

(I changed some characters to ## before posting for security.)


I am using 6.4.4 but it was doing it on the previous version also.

I checked .htaccess, no direct reference to storetgb in there.

The ini.inc.php code you refer to is from line 197:

// Automatically detect and assign the store url, and root relative path

$server_name = (!empty($_SERVER['HTTP_HOST'])) ? strtolower($_SERVER['HTTP_HOST']) :  strtolower($_SERVER['SERVER_NAME']);

$server_port = (!empty($_SERVER['SERVER_PORT'])) ? (int) $_SERVER['SERVER_PORT'] : 80;

$script_name = (isset($_SERVER['PHP_SELF']) && !empty($_SERVER['PHP_SELF'])) ? $_SERVER['PHP_SELF'] : $_SERVER['REQUEST_URI'];

$script_name = preg_replace('/[^a-z0-9-_.~\/]/i', '', $script_name);

$script_path = trim(dirname($script_name));

$script_path = str_replace('\\', '/', $script_path);

$script_path = preg_replace('#[\\\\/]{2,}#', '/', $script_path);

$url = (CC_SSL ? 'https://' : 'http://') . $server_name . $script_path;

$url = filter_var($url, FILTER_SANITIZE_STRING);


It's not the inclusion of dirname in bold above is it?

 

In PHP info I found this under "Session" section:

session.cookie_domain .ontas.net
session.cookie_path /storetgb


Under the "PHP variables" section the reference to links is to /storetgb/admin_########.php

 

The Documents\>>View Basket URL is:
https://ontas.net/storetgb/index.php?_a=basket

I don't remember customising it.

Thanks for your response and help.

 

Link to comment
Share on other sites

In admin, PHP Info, PHP Variables table, there will list pertinent $_SERVER variables.

When everything is working right (as it would when the latest page requested is an admin page from tasgingerbread.com), what are the relevant $_SERVER elements?

 

Link to comment
Share on other sites

Posted (edited)
$_SERVER['HTTP_HOST'] ontas.net
$_SERVER['HTTP_REFERER'] https://ontas.net/storetgb/admin_#####.php?_g=phpinfo

 

 

$_SERVER['HTTP_SEC_FETCH_SITE'] same-origin
$_SERVER['HTTP_SEC_FETCH_MODE'] navigate
$_SERVER['HTTP_SEC_FETCH_USER'] ?1
$_SERVER['HTTP_SEC_FETCH_DEST'] document

 

$_SERVER['DOCUMENT_ROOT'] /home2/abcedgec/public_html
$_SERVER['REMOTE_ADDR'] 8.39.202.58
$_SERVER['REMOTE_PORT'] 56760
$_SERVER['SERVER_ADDR'] 103.42.110.8
$_SERVER['SERVER_NAME'] ontas.net

 

$_SERVER['REQUEST_URI'] /storetgb/admin_########.php?_g=phpinfo


Last one I changed ####

 

Is this what you mean?
I'm off to work so wont respond for a while now.

Edited by edgetas
Link to comment
Share on other sites

Yes.

Of concern to me is that the HTTP_HOST is said to be "ontas.net", that the DOCUMENT_ROOT is at "/public_html/", and that you got to the admin (REQUEST_URI) via "/storetgb/admin_#.php".

I strongly recommend that you use the "tasgingerbread.com/admin_#.php" URL to access admin (as well as the storefront).

Once you get into admin, clear the cache, then log out, making sure that every web address you use is only "tasgingerbread.com" for everything.

(Please blank out the HTTP_REFERRER link above.)

Edited by bsmither
Link to comment
Share on other sites

Thank you very much for your help and patience. (Previous post edited - thanks, I missed that one.)
I have done as you suggested, been through the entire back-end looking for and changing references and it seems to be working correctly.
I noticed the entries changed in the PHP Variables Table when logging in under tasgingerbread.com/admin_#.php
I will monitor the situation and see if the solution persists.

Thanks for your time, I really appreciate your support and CubeCart.

Cheers,
Tone.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...