Post by catalinedward » Tue Aug 25, 2020 4:47 am

my site is www.hibike.ro
if you go to that adress the site looks weird, the buttons on "add to cart", wishlist, language etc don't load properly and when you click on them you get an "undefined error"
what i found on the internet is that i need to put in htaccess this code

# Canonical HTTPS/non-WWW
<IfModule mod_rewrite.c>
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\.hibike\.ro[NC]
RewriteRule (.*) https://hibike.ro/$1 [L,R=301]
</IfModule>

is this a good method?
and one more thing, can someone tell me where i put this? under what line? a picture would be great

Attachments

www.hibike.ro-1.png

how site looks when you go the page - www.hibike.ro-1.png (612.7 KiB) Viewed 1300 times


Newbie

Posts

Joined
Fri Aug 21, 2020 2:30 pm

Post by webocreation.com » Tue Aug 25, 2020 7:56 am

Your site is loading at http://www.hibike.ro/ but your CSS and JS are loading at http://hibike.ro/ by which it is creating the Access issue.

Code: Select all

Access to font at 'https://hibike.ro/catalog/view/javascript/font-awesome/fonts/fontawesome-webfont.woff2?v=4.7.0' from origin 'http://www.hibike.ro' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
So need to redirect all URL either to www.hibike.ro or hibike.ro.

First open config.php and see what URL are you using in it.

Code: Select all

<?php
// HTTP
define('HTTP_SERVER', 'http://www.hibike.ro/');
// HTTPS
define('HTTPS_SERVER', 'https://www.hibike.ro/');
If it similar to above then change your htaccess accordingly. To redirect your website from non-www to www, add the following lines in your website’s .htaccess file:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^hibike.ro [NC]
RewriteRule ^(.*)$ http://www.hibike.ro/$1 [L,R=301]

Hope this help.

Blog free tips and tricks
Free extensions
OpenCart Tutorials
OpenCart Tutorials Youtube Video for developers


User avatar
New member

Posts

Joined
Fri Feb 02, 2018 11:51 pm

Post by catalinedward » Tue Aug 25, 2020 2:28 pm

config looks like this:
<?php
// HTTP
define('HTTP_SERVER', 'https://hibike.ro/');

// HTTPS
define('HTTPS_SERVER', 'https://hibike.ro/');
so i should change https://hibike.ro/ to www.hibike.ro? i didnt change anything from the normal OC instalation.
i had a wp site, and removed it completly, and made the open cart instalation. should htaccess be hidden file? or the instalation didnt remove the old wp htaccess? sorry i started making this site few weeks ago.

htaccess looks like this:
RewriteOptions inherit
RewriteEngine On
#redirect http://mail.hibike.ro to WebMail interface
RewriteCond %{HTTP_HOST} ^mail.hibike.ro [NC]
RewriteRule ^(.*) https://hibike.ro:2096/ [L,R]

# 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
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php73” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php73 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
no ideea why wp is there

Newbie

Posts

Joined
Fri Aug 21, 2020 2:30 pm

Post by webocreation.com » Wed Aug 26, 2020 6:20 am

If you want www then use www URL in the config.php and add the redirect of www in htaccess, if you don't want www then use non-www URL in the config.php

Looks like there is old htaccess.
Check by changing all the htaccess content by the content at below
https://raw.githubusercontent.com/openc ... access.txt

Blog free tips and tricks
Free extensions
OpenCart Tutorials
OpenCart Tutorials Youtube Video for developers


User avatar
New member

Posts

Joined
Fri Feb 02, 2018 11:51 pm

Post by catalinedward » Wed Aug 26, 2020 5:13 pm

i tried with the original opencart htaccess, but it doesnt resolve the issue
now when you type hibike.ro it automaticly redirects you to www.hibike.ro but the page is as before
with buttons not working. it works normally if you press the home (logo) button. After you press that home button the link becomes https://www.hibike.ro/index.php?route=common/home
only now, the site works normally

Newbie

Posts

Joined
Fri Aug 21, 2020 2:30 pm

Post by letxobnav » Wed Aug 26, 2020 5:18 pm

no, https://hibike.ro/ stays there.
Clear your browser cache, 301 redirects are cached.
now you just have your fonts at www. which causes CORS issues.

Crystal Light Centrum Taiwan
Extensions: MailQueue | SUKHR | VBoces

“Data security is paramount at [...], and we are committed to protecting the privacy of anyone who is associated with our [...]. We’ve made a lot of improvements and will continue to make them.”
When you know your life savings are gone.


User avatar
Expert Member

Posts

Joined
Fri Aug 18, 2017 4:35 pm
Location - Taiwan

Post by catalinedward » Wed Aug 26, 2020 5:27 pm

i have added these 2 codes on htaccess at the bottom of the page. the second one resolved the issue. found the solution in another forum post from a older topic

RewriteEngine On
RewriteCond %{HTTP_HOST} ^hibike.ro [NC]
RewriteRule ^(.*)$ http://www.hibike.ro/$1 [L,R=301]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]

i went and put the www. in admin/config.cfg too
without that i could not etenr dashboard anymore. seems like for now it works
site and dashboard
Last edited by catalinedward on Wed Aug 26, 2020 5:45 pm, edited 1 time in total.

Newbie

Posts

Joined
Fri Aug 21, 2020 2:30 pm

Post by paulfeakins » Wed Aug 26, 2020 5:43 pm

Probably not the problem but you don't have to turn the rewrite engine on twice.

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by catalinedward » Wed Aug 26, 2020 5:47 pm

paulfeakins wrote:
Wed Aug 26, 2020 5:43 pm
Probably not the problem but you don't have to turn the rewrite engine on twice.
thank you. i managed to make it work somehow, i edited my post after some tries

Newbie

Posts

Joined
Fri Aug 21, 2020 2:30 pm

Post by khnaz35 » Wed Aug 26, 2020 6:03 pm

catalinedward wrote:
Wed Aug 26, 2020 5:47 pm
paulfeakins wrote:
Wed Aug 26, 2020 5:43 pm
Probably not the problem but you don't have to turn the rewrite engine on twice.
thank you. i managed to make it work somehow, i edited my post after some tries
you can share your solution here also so if someone have same problem can follow it.

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by catalinedward » Fri Aug 28, 2020 6:33 pm

the solution to my problem was:

in config.cfg change

Code: Select all

<?php
// HTTP
define('HTTP_SERVER', 'http://www.sitename.ro/');
// HTTPS
define('HTTPS_SERVER', 'https://www.sitename.ro/');
basicly you insert WWW instead of having https://sitename.ro/
then the same thing you have to do in the config file in admin folder to

Code: Select all

<?php
// HTTP
define('HTTP_SERVER', 'https://www.sitename.ro/admin/');
define('HTTP_CATALOG', 'https://www.sitename.ro/');

// HTTPS
define('HTTPS_SERVER', 'https://www.sitename.ro/admin/');
define('HTTPS_CATALOG', 'https://www.sitename.ro/');
if you don't add www to the code in admin config, you will not be able to login into the dashboard anymore. the www must appear in both config.cfg files

next step
in the .htaccess file add

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sitename.ro [NC]
RewriteRule ^(.*)$ http://www.sitename.ro/$1 [L,R=301]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
i pasted this at the end of the htaccess file.

replace SITENAME with your site name and replace the .ro to whatever you have. Don't replace anything else just copy/paste.
beeing new i was thinking if i had to change things like SERVER_NAME or server_port. Don't change them

my problem was bigger since when i deleted wordpress and installed opencart, i didnt delete the hidden files too (didnt know there were hidden files), so the new opencart instalation didn't add a new htaccess file. i deleted the former .htaccess file and copied the opencart file from the instalation archive.

again thank you for the help.

Newbie

Posts

Joined
Fri Aug 21, 2020 2:30 pm

Post by khnaz35 » Fri Aug 28, 2020 7:01 pm

catalinedward wrote:
Fri Aug 28, 2020 6:33 pm
the solution to my problem was:

in config.cfg change

Code: Select all

<?php
// HTTP
define('HTTP_SERVER', 'http://www.sitename.ro/');
// HTTPS
define('HTTPS_SERVER', 'https://www.sitename.ro/');
basicly you insert WWW instead of having https://sitename.ro/
then the same thing you have to do in the config file in admin folder to

Code: Select all

<?php
// HTTP
define('HTTP_SERVER', 'https://www.sitename.ro/admin/');
define('HTTP_CATALOG', 'https://www.sitename.ro/');

// HTTPS
define('HTTPS_SERVER', 'https://www.sitename.ro/admin/');
define('HTTPS_CATALOG', 'https://www.sitename.ro/');
if you don't add www to the code in admin config, you will not be able to login into the dashboard anymore. the www must appear in both config.cfg files

next step
in the .htaccess file add

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} ^sitename.ro [NC]
RewriteRule ^(.*)$ http://www.sitename.ro/$1 [L,R=301]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
i pasted this at the end of the htaccess file.

replace SITENAME with your site name and replace the .ro to whatever you have. Don't replace anything else just copy/paste.
beeing new i was thinking if i had to change things like SERVER_NAME or server_port. Don't change them

my problem was bigger since when i deleted wordpress and installed opencart, i didnt delete the hidden files too (didnt know there were hidden files), so the new opencart instalation didn't add a new htaccess file. i deleted the former .htaccess file and copied the opencart file from the instalation archive.

again thank you for the help.
Thank you for pasting your solution, hopefully will save many of ours time and solve the similar issues for many.
kindly add the word [SOLVED] in beginning of your post title.

Urgent Questions shoot here: khnaz35@gmail.com
Enjoy nature ;) :) :-*


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia
Who is online

Users browsing this forum: No registered users and 138 guests