Post by aarslankhan » Fri Sep 06, 2019 6:44 pm

Hello to Everybody
Coming to forum have always been helpful. Sure somebody will help me again. I need if some user enters my domain name in the address bar, for example www.mysite.com, it should redirect to www.mysite.com/abc for example, without requring the user to enter www.mysite.com/abc in the address bar. I do not want to install Opencart in www.mysite.com/abc. How can I solve this? I would be thankful for your help. I am using Opencart version 3.0.2.0.

Kind Regards,
aarslankhan

New member

Posts

Joined
Tue Mar 20, 2018 3:11 pm

Post by letxobnav » Fri Sep 06, 2019 8:49 pm

.htaccess

RewriteRule ^$ /abc [R=301,L]

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 aarslankhan » Fri Sep 06, 2019 11:31 pm

Thanks letxobnav for your kind and quick response. I have added your advised code at the bottom of .htaccess file. Code is working as I required. Thanks. When I entered www.mysite.com and it redirected to www.mysite.com/abc. But it gave an error " The page you requested cannot be found". At the moment I have some content at www.mysite.com. What actually I want is that when user enters www.mysite.com then it should redirect to www.mysite.com/abc and the user should see the same content at www.mysite.com/abc which user would have seen at www.mysite.com. Meaning that when user enters www.mysite.com, it should redirect to www.mysite.com/abc with the content of www.mysite.com. I do not want to install my content in www.mysite.com/abc. It should remain in www.mysite.com. Thanks.
Kind Regards
aarslankhan

New member

Posts

Joined
Tue Mar 20, 2018 3:11 pm

Post by xxvirusxx » Fri Sep 06, 2019 11:57 pm

Why you want to redirect www.something.com/abc (if you don't want to install here) to www.something.com

In this case....add redirection to 404 so when type www.something.com/sdfsdfsdf redirect to www.something.com

You want to make Multistore? or what?

Upgrade Service | OC 2.3.0.2 PHP 8 | My Custom OC 3.0.3.8 | Buy me a beer


User avatar
Expert Member

Posts

Joined
Tue Jul 17, 2012 10:35 pm
Location - România

Post by aarslankhan » Sat Sep 07, 2019 12:40 am

xxvirusxx thanks for your kind reply. Actually I want to redirect www.something.com to www.something.com/abc. I want to simply keep data at www.something.com and redirect it to www.something.com/abc because I have found in google that it is good for the security of one's website. Can you please elaborate your answer. How can Implement 404 redirection if it fulfills my purpose. Thanks.
Kind Regards
aarslankhan

New member

Posts

Joined
Tue Mar 20, 2018 3:11 pm

Post by letxobnav » Sat Sep 07, 2019 8:31 am

If there is nothing under /abc then you need to remove that part of the _route_ in startup.
(if you want /abc added to every url your site produces you will have to insert it again in the seo_url class)
I use the same principle but for adding the language to the url as in en/ or zh/.

so in catalog/controller/startup/startup.php class you need to add:

Code: Select all

if (isset($this->request->get['_route_'])) $this->request->get['_route_'] = str_replace('/abc','',$this->request->get['_route_']);
to remove that /abc part from the _route_ for processing to prevent a 404.

not sure where you got the idea about security as it makes no sense, if it is to obfuscate where the sources reside, forget it.

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 aarslankhan » Sat Sep 07, 2019 1:15 pm

letxobnav I am greately thankful for your kind response and time. please tell me where I have to add the code "if (isset($this->request->get['_route_'])) $this->request->get['_route_'] = str_replace('/abc','',$this->request->get['_route_']);". I have to add it at the end of startup.php file or elsewhere. Please tell me the line beneath which I have to add this code. Sorry, one more question. Will I have to remove the code "RewriteRule ^$ /abc [R=301,L]" from htaccess file , you earlier told me to add in the htaccess file to add the new code to startup.php file or not. If I have to remove this, I deleted the code "RewriteRule ^$ /abc [R=301,L]" from at the end of htacccess file and saved the file and also cleared the cache. But still my www.mysite.com is redirecting to www.mysite.com/abc even after deleting the code from htaccess file. Please tell me how to solve this, if I have to add the new code in startup.php after deleting from htaccess file. Your help will be great for me.
Thanks
Kind Regards
aarslankhan

New member

Posts

Joined
Tue Mar 20, 2018 3:11 pm

Post by letxobnav » Sun Sep 08, 2019 2:30 pm

301 redirects are browser cached so clear your browser cache if you removed the redirect from htaccess or make it a 302 redirect.

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 aarslankhan » Mon Sep 09, 2019 3:07 pm

letxobnav I am greately thankful for your great help and time. :)

New member

Posts

Joined
Tue Mar 20, 2018 3:11 pm
Who is online

Users browsing this forum: Bing [Bot] and 258 guests