-1

I have changed config file in opencart from http://mywebsite.in/ to http://www.mywebsite.in/ .

Now the problem is when i visit mywebsite.in, the website doesn't work. How can i redirect to www or http.

do i need to do something in library/url.php

public function link($route, $args = '', $secure = false) { if ($this->ssl && $secure) { $url = 'https://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/.\') . '/index.php?route=' . $route; } else { $url = 'http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/.\') . '/index.php?route=' . $route; }

    if ($args) {
        if (is_array($args)) {
            $url .= '&' . http_build_query($args);
        } else {
            $url .= str_replace('&', '&', '&' . ltrim($args, '&'));
        }
    }

Please help me. Thanks alot in advance.

Aditya
  • 25
  • 1
  • 7

1 Answers1

0

Aditya, You need to make .htaccess file in root folder and then do following changes on that file.

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

It will forcefully redirect to www. If it's work then give me whote.

Vipul Jethva
  • 647
  • 1
  • 7
  • 27
  • It still doesn't work, if i go to any inner page, and click on home through navigation then it redirecting to mywebsite.in only. its oc 2.2 and i dont know whats wrong with these htaccess and config files. please help me. – Aditya Apr 28 '16 at 11:35
  • # BEGIN WordPress RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] RewriteEngine On RewriteCond %{HTTP_HOST} ^mywebsite.in$ RewriteRule (.*) http://www.mywebsite.in/$1 [R=301,L] # END WordPress This is my htacess file. – Aditya Apr 28 '16 at 11:38
  • can we do something to work website on mywebsite.in domain. instead of putting http or www before url? – Aditya Apr 28 '16 at 12:05
  • @Aditya Do you enable "Use SEO URLs" option in admin → system → setting → server tab ? This should be enable otherwise your .htaccess file will not work. – Vipul Jethva Apr 28 '16 at 12:48
  • it is already enabled. i will provide you the domain : shreejifoods.in – Aditya Apr 28 '16 at 12:51
  • @Aditya It's working fine. When I tried to use URL shreejifoods.in so it is redirected to www URL. Tried to other browser or clear cookies. – Vipul Jethva Apr 28 '16 at 12:53
  • http://shreejifoods.in/index.php?route=product/category&path=60_64 visit this. and see its not redirecting to www. and website doesnt work – Aditya Apr 28 '16 at 13:03
  • Don't change any core file of file php and verify your .htaccess code with ` Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^shreejifoods.in$ RewriteRule (.*) http://www.shreejifoods.in/$1 [R=301,L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA] ` – Vipul Jethva Apr 28 '16 at 13:06
  • verify means should i replace the code? with your code? – Aditya Apr 28 '16 at 13:08
  • Yes @Aditya, You will try my code in .htaccess file and if you did any change on seo_url.php (controller) then make it opencart original code. This code is work fine in my project. – Vipul Jethva Apr 28 '16 at 13:12
  • ok i havnt change anything in any php file. let me try your code. lets see.. i will let you know. – Aditya Apr 28 '16 at 13:16
  • @Aditya Give me Upwhote my ans if it's really useful. – Vipul Jethva May 03 '16 at 12:22