Page 1 of 1

[HOW TO] Redirect "index.php?route=common/home" to main page

Posted: Wed Jul 21, 2010 10:38 am
by Johnathan
To redirect the home URL (http://www.yoursite.com/index.php?route=common/home) to your store's main page (http://www.yoursite.com), add the following code to your .htaccess file below the RewriteBase line:

Code: Select all

RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://%{HTTP_HOST}? [R=301,L]
Note that this won't change the actual links in your store, but once clicked on, they'll redirect to the main page without the "index.php?route=common/home" portion.

More tutorials are available at OpenCartX.com/tutorials

Re: [HOW-TO] Rewrite "index.php?route=common/home" to main p

Posted: Wed Jul 21, 2010 11:14 pm
by helenmarie
brilliant, thank you ;D

Re: [HOW TO] Rewrite "index.php?route=common/home" to main p

Posted: Thu Apr 05, 2012 5:08 pm
by latty82
Cheers Johnathan you're a legend! ;D

Re: [HOW TO] Rewrite "index.php?route=common/home" to main p

Posted: Sun Jun 10, 2012 10:50 pm
by elion
Thank you, Johnathan!

I had thought to do this by changing the code, it was a faulty method.

Re: [HOW TO] Rewrite "index.php?route=common/home" to main p

Posted: Mon Jul 23, 2012 4:09 am
by paulseer
What would the code be if you are running multistore, would you use the main domain here?

Re: [HOW TO] Rewrite "index.php?route=common/home" to main p

Posted: Mon Jul 23, 2012 4:17 am
by paulseer
ah forget that just found it and for any one wondering it is

RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteRule ^index\.php$ /? [R=301,L]

So if you are running multistore this is the one

Re: [HOW TO] Rewrite "index.php?route=common/home" to main p

Posted: Sun Aug 12, 2012 3:11 pm
by nikespacessale
nice, it works for my site, much better than modify code..thanks.

Re: [HOW TO] Rewrite "index.php?route=common/home" to main p

Posted: Tue Oct 15, 2013 3:17 pm
by AriesM
Hi Jonathan,
I'm having difficulty implementing the .htacess trick. If you look at http://goo.gl/0jlCJ5, logo and bread crumbs still links to "index.php?route=common/home"

Re: [HOW TO] Redirect "index.php?route=common/home" to main

Posted: Thu Oct 17, 2013 11:04 pm
by Johnathan
I revised the description in the original post to make this clearer, but this edit only redirects the common/home URL to the main page. It doesn't change the actual link, but there are some edits that can do that in this topic:

http://forum.opencart.com/viewtopic.php?f=20&t=13107

Re: [HOW TO] Redirect "index.php?route=common/home" to main

Posted: Fri Oct 18, 2013 2:51 am
by rivera2419
Hi Johnathan,

I have an external website that adds items to the cart. Is there an htaccess modification to redirect the "Continue Shopping" button on the cart back to the specific URL of my website product page?

Thanks!

Re: [HOW TO] Redirect "index.php?route=common/home" to main

Posted: Fri Oct 18, 2013 4:43 am
by Johnathan
Unfortunately no, because that button is hard-coded to link back to the main page. You'd need to have someone modify your installation to read some data from the URL when adding to the cart, so it could change the behavior of the button dynamically.

If you need to find a developer, I recommend you post a request in the OpenCart "Commercial Support" forum (forum.opencart.com/viewforum.php?f=88), which is checked by a number of OpenCart developers. You can also try checking out the OpenCart "Partners" area (www.opencart.com/index.php?route=partner/partner).

Re: [HOW TO] Redirect "index.php?route=common/home" to main

Posted: Fri Oct 18, 2013 6:53 am
by rivera2419
Thank you very much....I'll do so.

Re: [HOW TO] Redirect "index.php?route=common/home" to main

Posted: Thu Dec 26, 2013 2:25 am
by latino
Hi, it works for home page but after that I deleted the code from .htaccess just to undo it.
but it still doesnt show following address like always..index.php?route=common/home

Why is that?
can I do this trick for other pages. category, product etc.?

Cheers

Re: [HOW TO] Redirect "index.php?route=common/home" to main

Posted: Mon Dec 30, 2013 12:07 am
by Johnathan
Are you sure the link is actually going to common/home? If it's set to go to just your domain, that URL will still work. Both with and without common/home are valid URLs for the store.

Redirecting other pages is more complex, and although it can be done with .htaccess, it requires knowledge of how to create the redirects. If you don't have this, you might consider Redirect Manager.

Re: [HOW TO] Redirect "index.php?route=common/home" to main page

Posted: Fri Apr 20, 2018 6:55 pm
by radi8tor
Hi Jonathan,

How can I get this to work, as this is not working for me:

Code: Select all

RewriteBase /
RewriteRule ^sitemap.xml$ index.php?route=extension/feed/yandex_sitemap [L]
RewriteRule ^googlebase.xml$ index.php?route=extension/feed/google_base [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteCond %{QUERY_STRING} ^route=common/home$
RewriteCond %{REQUEST_METHOD} !^POST$
RewriteRule ^index\.php$ http://%{HTTP_HOST}? [R=301,L]
Thanks!

Re: [HOW TO] Redirect "index.php?route=common/home" to main page

Posted: Fri Apr 20, 2018 8:51 pm
by MrPhil
You've got 5 RewriteCond (rewrite conditions) in a row, and the default operation is AND. That is, all 5 must be true in order for the RewriteRule(s) following to be run. You may need to restructure these rules with some [OR] flags, or may even need to break it up into several groups of rewrites. Sorry, but even the makers of .htaccess (Apache) concede that this is all "voodoo" (difficult to understand and write).

Re: [HOW TO] Redirect "index.php?route=common/home" to main page

Posted: Wed Apr 25, 2018 1:24 pm
by radi8tor
Hi,

It turned out that my site does not having Apache webserver. :)

I solved it using this guide's method #2: https://isenselabs.com/posts/how-to-rem ... 23x-and-3x