Zen Cart Logo
Forums / General Questions / 301 redirect in htaccess not working

301 redirect in htaccess not working

Locked

Views: 8,073

Results 1 to 11 of 11
This thread is locked. New replies are disabled.
23 Aug 2007, 4:41 PM
#1
frenchfrog avatar

frenchfrog

New Zenner

Join Date:
Jan 2007
Posts:
65
Plugin Contributions:
0

301 redirect in htaccess not working

Hi there

I'm tring to do a 301 redirect to have a "category alias" (I think it would be a smart way to avoid the creation another category and duplicating items, since there is a bunch od subcategories in it)

so basically I would like to achieve a:

redirect 301 /store/index.php?main_page=index&cPath=7  http://www.thedomain.com/store/index.php?main_page=index&cPath=1

so when one clicks on the category 7, they open teh category 1

but unfortunately, it seems that everything after the questionmark is not recognized.

Any suggestions (maybe with a rewrite rule, where I'm no expert?)

Thanks!

23 Aug 2007, 9:33 PM
#3
frenchfrog avatar

frenchfrog

New Zenner

Join Date:
Jan 2007
Posts:
65
Plugin Contributions:
0

Re: 301 redirect in htaccess not working

this works:

redirect 301 /store/test.html http://www. thedomain.com/store/index.php?main_page=index&cPath=1

but this:

redirect 301 /store/index.php http://www. thedomain.com/store/index.php?main_page=index&cPath=1

gives me a:

Too many redirects occurred trying to open “http://www.thedomain.com/store/index.php?main_page=index&cPath=1”.

23 Aug 2007, 9:41 PM
#4
superprg avatar

superprg

Totally Zenned

Join Date:
Feb 2006
Location:
Chicago
Posts:
1,349
Plugin Contributions:
0

Re: 301 redirect in htaccess not working

In place of ?, = etc in the first url to be redirected can you put the html values and try?

23 Aug 2007, 9:48 PM
#5
frenchfrog avatar

frenchfrog

New Zenner

Join Date:
Jan 2007
Posts:
65
Plugin Contributions:
0

Re: 301 redirect in htaccess not working

I don't understand what you want me to do :-)

my url is:

/store/index.php?main_page=index&cPath=7

I don't see what I can replace in that

(please note I'm not working with SEO URLs at all, it's pure ZC urls I'm trying to redirect)

23 Aug 2007, 10:49 PM
#6
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: 301 redirect in htaccess not working

Rewriting addresses that contain & and = parameters is often quite complex in .htaccess.

Try explaining again what you want to accomplish. Pretend you know nothing about htaccess and ways to do redirects. What is the situation you have now and what do you want to end up with? Maybe there's an easier or better way to get there ...

23 Aug 2007, 10:55 PM
#7
frenchfrog avatar

frenchfrog

New Zenner

Join Date:
Jan 2007
Posts:
65
Plugin Contributions:
0

Re: 301 redirect in htaccess not working

A client with a store containing hunfreds of categories asked us to create "mirror categories": they don't want to create item "aliases" during the listing process (item listed in several categories), so we are trying to make a "dummy category" whose sole purpose will be to redirect to the category that has the items in it.

The category in question has dozens of subcategories and we think this is not the best way to go. A redirect seemed to be the easiest way to handle this...

Thank you for your help.

23 Aug 2007, 11:13 PM
#8
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: 301 redirect in htaccess not working

And this is for just "one" category to be redirected, right?

Is this a top-level category, or is it a subcat ?

23 Aug 2007, 11:15 PM
#9
frenchfrog avatar

frenchfrog

New Zenner

Join Date:
Jan 2007
Posts:
65
Plugin Contributions:
0

Re: 301 redirect in htaccess not working

actually, we would have several, some are subcats

23 Aug 2007, 11:32 PM
#10
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: 301 redirect in htaccess not working

Try this:

  1. copy the /includes/init_includes/init_category_path.php file to the/includes/init_includes/overrides folder.

  2. edit the new file in the overrides folder.
    Near the bottom of the file (around line 40) you'll see this:$this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) ); ?>insert some extra code before the last line, like this:```
    $this_is_home_page = ($current_page=='index' && (!isset($_GET['cPath'])) && (!isset($_GET['manufacturers_id'])) && (!isset($_GET['typefilter'])) );
    [B]
    // redirect certain categories to others, instead of the usual approach of cross-linking products to alternate categories via the admin
    $newPath = '';
    if ($cPath == '3_12') $newPath = '54_60';
    if ($cPath == '22') $newPath = '2_19';

if ($newPath != '') {
header("HTTP/1.1 301 Moved Permanently");
zen_redirect(zen_href_link(FILENAME_DEFAULT, 'cPath=' . $newPath));
}[/B]
?>

Substitute the **cPath and newPath values as needed. Duplicate as needed.**
23 Aug 2007, 11:36 PM
#11
frenchfrog avatar

frenchfrog

New Zenner

Join Date:
Jan 2007
Posts:
65
Plugin Contributions:
0

Re: 301 redirect in htaccess not working

hahahahhhhh I BUY THIS ONE!

Thank you Doctor, I'm feeling much better now :-)

Have a great day!