Post by BbWebConsult » Thu Jan 27, 2011 9:26 pm

Hi!

I noticed a strange thing. When SEO URL's are activated, there is a display problem in the pages stored in Google's cache.
The pages are not displayed correctly and some pictures don't show.

This only occurs when SEO is activated and on particular pages like
http://www.example.com/manufacturer/product-name

I tracked down the problem and discovered that it was due to <base href=""/>
Indeed, Opencart uses <base href="http://....." /> to tell the browser that all relative paths should use the base url. (stylesheet, images)

The problem is that google overrides <base href=""> and uses "http://www.example.com/manufacturer/product-name" (the real url of the cached current page) as the new base.
Which means that when you call "catalog/view/theme/your_theme/stylesheets/style.css" the browser will try to call
"http://www.example.com/manufacturer/catalog/view/theme/your_theme/stylesheets/style.css"
This is of course not correct, the right path is "http://www.example.com/catalog/view/theme/your_theme/stylesheets/style.css"

So, if the stylesheets are not loaded, the display is altered. :-[

How to solve this issue?
Well, it's quite simple. If your store is at the root of your domain, just add a "/" in front of each external file call.
=> "/catalog/view/theme/your_theme/stylesheets/style.css".

If your store is in a subdirectory you will have to name the subdirectory :
"/subdirectory/catalog/view/theme/your_theme/stylesheets/style.css"

But if you change your store's directory, you will have to change all the paths again

Now, this is not really an issue due to Opencart, I would say that Google does not handle this well.
google should not override your <base> url.

Moreover, if you designed your own template, maybe you will not have this problem if you did not use <base href>.
I had this problem because I designed my own template using the default template of Opencart as an example.

That is no big deal; this is just for some pages and only when viewing the page from Google's cache. But, let's do things correctly ;)

PS: All products images display correctly as opencart references them to their complete path: <img src="http://www.example.com/image/data/image.jpg" />

So, this is in fact a problem related to the template.

PS2: This problem also occurs with the captcha image.

Diseño web Barcelona


User avatar
Newbie

Posts

Joined
Tue Jan 25, 2011 4:18 am


Post by Xsecrets » Thu Jan 27, 2011 9:42 pm

Well this is certainly a google problem not an opencart problem, and designing a template without base would simply cause the problem to occur for real visitors to your site. because then they would be looking for the images in the wrong place. I'm really surprised that google has such a glaring bug, but I'm sure one of the geniuses over there has some sort of reason for it though I can't for the life of me think of what it could be.

OpenCart commercial mods and development http://spotonsolutions.net
Layered Navigation
Shipment Tracking
Vehicle Year/Make/Model Filter


Guru Member

Posts

Joined
Sun Oct 25, 2009 3:51 am
Location - FL US

Post by storm-cloud » Sun Aug 05, 2012 11:28 am

I know this is a very old post but I have just been looking into resolving this problem.

To add to the original post, I don't think this strictly pertains to SEO URL's or OpenCart.

Google's cache adds a base href attribute for every page in their cache. This doesn't only apply to OpenCart sites but every single page that is cached. Rather than overriding this tag as mentioned in the original post, there is actually two base href attributes for each cached page. As this additional base tag incorrectly references the complete URL for each relative page, this in turn breaks the links to the required resources.

The odd thing is that any single level pages are in fact cached correctly. For example...

Code: Select all

http://www.website.com/first-level-store-page
.

It is only when there is a second level or more that Google's cache has issues. For example...

Code: Select all

http://www.website.com/first-level-store-page/second-level-store-page
This may also be why when SEO URL's are not enabled that everything displays correctly as all URL's are single level.

I am aware that a forward slash can be added in front of each URL that references the base tag in order to load the resource correctly. However, considering the large number of vQmod's in use for our store, this may prove to be a meticulous task that requires ongoing maintenance during upgrades or module changes etc. Personally, I feel this is something that Google should rectify on their end. I have posted this issue in their forums but I don't hold much hope for a fix.

Out of curiosity, has a fix been discovered that doesn't require adding a forward slash in front of each URL?

Active Member

Posts

Joined
Wed Feb 22, 2012 8:07 am

Post by P_mudev » Mon Apr 19, 2021 4:47 pm

Hello,
I have the same problem.
When SEO is On, the site is loading correctly only "first-level-item-or-menus". When i go in any sub first-category-item the CSS and JS are not loading, as there are non. This is something very simple, but I can not figure out how to fix it.
Can someone help me with this? Thank you.

Newbie

Posts

Joined
Sun Jan 17, 2021 12:27 am
Who is online

Users browsing this forum: No registered users and 6 guests