Post by katalin » Sat Mar 25, 2023 11:22 pm

Hello, how can I redirect with htaccess the following:
index.php?route=product/catalog to index.php

I tried to redirect from cpanel and it redirects to ?route=product/catalog
Last edited by katalin on Fri Apr 07, 2023 4:07 am, edited 1 time in total.

Active Member

Posts

Joined
Wed May 05, 2010 2:28 am

Post by TMD Extension @ » Mon Mar 27, 2023 8:22 pm

If you are looking for a simple way then open the header.php file of your theme. then use the

301 > permanent redirect
302 > temporary redirect

function redirect($url, $statusCode = 302) {
header('Location: ' . $url, true, $statusCode);
die();
}



function areUrlsTheSame($url1, $url2)
{
$mustMatch = array_flip(['host', 'port', 'path']);
$defaults = ['path' => '/']; // if not present, assume these (consistency)
$url1 = array_intersect_key(parse_url($url1), $mustMatch);
$url2 = array_intersect_key(parse_url($url2), $mustMatch);

return $url1 === $url2;
}


TO match the current URL with the URL that you want to redirect then use the areUrlsTheSame function. if they match then call the
Redirect('https://yourwebsite.com/index/', false);

Image

Thanks & Regards
Sehaj Kaur
TMD Extensions
Contact Us For Customisations


Active Member

Posts

Joined
Thu Mar 17, 2022 12:59 pm

Post by by mona » Mon Mar 27, 2023 10:17 pm

no idea as to why you would want to but:

Code: Select all

RewriteCond %{QUERY_STRING} ^route=product/catalog$ [NC]
RewriteRule .* https://YOURDOMAIN/index.php [R=301,L]

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by JNeuhoff » Tue Mar 28, 2023 6:30 pm

There is no 'product/catalog' route anywhere in OpenCart 3. Please provide more details according to the forum rules.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by katalin » Wed Mar 29, 2023 2:56 am

by mona wrote:
Mon Mar 27, 2023 10:17 pm
no idea as to why you would want to but:

Code: Select all

RewriteCond %{QUERY_STRING} ^route=product/catalog$ [NC]
RewriteRule .* https://YOURDOMAIN/index.php [R=301,L]
If I browse index.php?route=product/catalog it redirects to https://example.com/?route=product/catalog and if I browse this is doesn't redirect at all.

Active Member

Posts

Joined
Wed May 05, 2010 2:28 am

Post by by mona » Wed Mar 29, 2023 4:47 am

Try

Code: Select all

RewriteCond %{QUERY_STRING} ^route=product/catalog$ [NC]
RewriteRule .* https://YOURDOMAIN/index.php [QSD,R=301,L]
You will probably have more luck with an extension.
I can recommend this one
https://www.opencart.com/index.php?rout ... on_id=5388

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by katalin » Tue Apr 04, 2023 5:38 am

by mona wrote:
Wed Mar 29, 2023 4:47 am
Try

Code: Select all

RewriteCond %{QUERY_STRING} ^route=product/catalog$ [NC]
RewriteRule .* https://YOURDOMAIN/index.php [QSD,R=301,L]
You will probably have more luck with an extension.
I can recommend this one
https://www.opencart.com/index.php?rout ... on_id=5388
Works now. Thanks a lot!

Active Member

Posts

Joined
Wed May 05, 2010 2:28 am

Post by katalin » Sun Apr 09, 2023 3:15 am

by mona wrote:
Wed Mar 29, 2023 4:47 am
Try

Code: Select all

RewriteCond %{QUERY_STRING} ^route=product/catalog$ [NC]
RewriteRule .* https://YOURDOMAIN/index.php [QSD,R=301,L]
You will probably have more luck with an extension.
I can recommend this one
https://www.opencart.com/index.php?rout ... on_id=5388
How about redirecting all www links to non www. Can you help with this? Thanks!

Active Member

Posts

Joined
Wed May 05, 2010 2:28 am

Post by by mona » Mon Apr 10, 2023 5:39 am

try

Code: Select all

RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by katalin » Mon Apr 10, 2023 9:11 pm

by mona wrote:
Mon Apr 10, 2023 5:39 am
try

Code: Select all

RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [L,R=301]
Works great. What do you think it would be better to use, www or non www?

Active Member

Posts

Joined
Wed May 05, 2010 2:28 am

Post by by mona » Mon Apr 10, 2023 10:43 pm

I do complete design work, often I use without, sometimes I use www.xxx.com rather than writing web (or similar) on a business card, sometimes the logo contains www.xxx.com, so that is what the site will be. All just depends on the whole concept and what / who is doing the other things that are going on and just keeping it constant.

I should have mentioned if you want to hardcode your url for security

Code: Select all

RewriteRule ^(.*)$ https://YOURDOMAIN/$1 [L,R=301]

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by katalin » Tue Apr 11, 2023 1:06 am

by mona wrote:
Mon Apr 10, 2023 10:43 pm
I do complete design work, often I use without, sometimes I use www.xxx.com rather than writing web (or similar) on a business card, sometimes the logo contains www.xxx.com, so that is what the site will be. All just depends on the whole concept and what / who is doing the other things that are going on and just keeping it constant.

I should have mentioned if you want to hardcode your url for security

Code: Select all

RewriteRule ^(.*)$ https://YOURDOMAIN/$1 [L,R=301]
Got it. Thanks for the help!

Active Member

Posts

Joined
Wed May 05, 2010 2:28 am
Who is online

Users browsing this forum: alanjones and 81 guests