Post by Johnathan » Wed Jul 21, 2010 10:38 am

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
Last edited by Johnathan on Wed Jul 23, 2014 12:50 am, edited 3 times in total.
Reason: Upated code so it should work without explicitly specifying the domain name

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by helenmarie » Wed Jul 21, 2010 11:14 pm

brilliant, thank you ;D

User avatar
New member

Posts

Joined
Sat Nov 07, 2009 1:05 am

Post by latty82 » Thu Apr 05, 2012 5:08 pm

Cheers Johnathan you're a legend! ;D

Newbie

Posts

Joined
Sun Apr 01, 2012 9:58 pm

Post by elion » Sun Jun 10, 2012 10:50 pm

Thank you, Johnathan!

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

Newbie

Posts

Joined
Thu Dec 17, 2009 9:06 pm

Post by paulseer » Mon Jul 23, 2012 4:09 am

What would the code be if you are running multistore, would you use the main domain here?

New member

Posts

Joined
Sun Jun 24, 2012 4:03 am

Post by paulseer » Mon Jul 23, 2012 4:17 am

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

New member

Posts

Joined
Sun Jun 24, 2012 4:03 am

Post by nikespacessale » Sun Aug 12, 2012 3:11 pm

nice, it works for my site, much better than modify code..thanks.

http://www.handbags002.com/ - your best choice for handbags.



Posts

Joined
Fri Aug 03, 2012 10:06 am
Location - usa

Post by AriesM » Tue Oct 15, 2013 3:17 pm

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"

Newbie

Posts

Joined
Tue Oct 15, 2013 3:05 pm

Post by Johnathan » Thu Oct 17, 2013 11:04 pm

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

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by rivera2419 » Fri Oct 18, 2013 2:51 am

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!

Newbie

Posts

Joined
Fri Oct 11, 2013 7:04 am

Post by Johnathan » Fri Oct 18, 2013 4:43 am

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).

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by rivera2419 » Fri Oct 18, 2013 6:53 am

Thank you very much....I'll do so.

Newbie

Posts

Joined
Fri Oct 11, 2013 7:04 am

Post by latino » Thu Dec 26, 2013 2:25 am

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

Newbie

Posts

Joined
Thu Dec 26, 2013 2:21 am

Post by Johnathan » Mon Dec 30, 2013 12:07 am

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.

Image
Image Image Image Image Image Image


User avatar
Global Moderator

Posts

Joined
Fri Dec 18, 2009 3:08 am


Post by radi8tor » Fri Apr 20, 2018 6:55 pm

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!

New member

Posts

Joined
Thu Feb 01, 2018 6:21 pm

Post by MrPhil » Fri Apr 20, 2018 8:51 pm

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).

User avatar
Active Member

Posts

Joined
Wed May 10, 2017 11:52 pm

Post by radi8tor » Wed Apr 25, 2018 1:24 pm

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

New member

Posts

Joined
Thu Feb 01, 2018 6:21 pm
Who is online

Users browsing this forum: No registered users and 1 guest