Zen Cart Logo
Forums / All Other Contributions/Addons / Odd Category Redirect - using SSU

Odd Category Redirect - using SSU

Locked

Views: 1,928

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
11 Jun 2010, 12:02 PM
#1
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Odd Category Redirect - using SSU

I have a category "A" that is for some reason, redirecting to category "B". Category "B" was also disabled in the zenCart admin months ago.

I have specifically set up my .htaccess to redirect category "B" to category "C" - which isn't working. All of the other redirects in my .htaccess are working.

Has anyone run into this situation before - where a category suddenly redirects to another? I need to get my category "A" up and running again, is it's responsible for about 15% of my sales.

11 Jun 2010, 12:30 PM
#2
g1smd avatar

g1smd

Zen Follower

Join Date:
Mar 2010
Location:
UK
Posts:
449
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

Let's see your code...

12 Jun 2010, 10:23 AM
#3
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

BOF SSU

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteRule ^shop/CategoryB$ http://www.mysite.com/CategoryC [R=301,L]
RewriteRule ^shop/CategoryB/CategoryB-(.*)$ http://www.mysite.com/CategoryC/CategoryC-$1 [R=301,L]

RewriteRule ^shop/(.*)$ http://www.mysite.com/$1 [R=301,L]
RewriteRule ^shop$ http://www.mysite.com/ [R=301,L]
RewriteRule ^index.html$ http://www.mysite.com/ [R=301,L]

RewriteBase /

Deny access from .htaccess

RewriteRule ^.htaccess$ - [F]

RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 [E=VAR1:$1,QSA]

EOF SSU

Note that some of the rules are from re-directing the links from the old location of the store (mydomain.com/shop) to the new location (mydomain.com).

As you can see, CategoryA isn't even mentioned in the .htaccess.

12 Jun 2010, 2:48 PM
#4
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

Forgot to mention that I'm running SSU.

12 Jun 2010, 2:53 PM
#5
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

After poking around the .htaccess (and my webhost breaking the site by modifying the .htaccess for me) I figured it had to be something to do with SSU. I had already tried resetting the category cache so I went ahead ran the "check and fix cache (run this once...)" and everything seems to be working again.

Case closed.

12 Jun 2010, 7:59 PM
#6
g1smd avatar

g1smd

Zen Follower

Join Date:
Mar 2010
Location:
UK
Posts:
449
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

Rule order optimised, added escaping in patterns, added non-www to www canonicalisation, and rewrite re-coded for better server efficiency:

# SSU SetUp
Options +FollowSymLinks -MultiViews
RewriteEngine On

# Deny access to .htaccess
RewriteRule ^\.htaccess$ - [F]

# The "/" is the default value so remove the following line
# RewriteBase /

# Custom Redirects
RewriteRule ^index\.html$ http://www.example.com/ [R=301,L]
RewriteRule ^shop/CategoryB$ http://www.example.com/CategoryC [R=301,L]
RewriteRule ^shop/CategoryB/CategoryB-(.*)$ http://www.example.com/CategoryC/CategoryC-$1 [R=301,L]
RewriteRule ^shop(/index\.html)?$ http://www.example.com/shop/ [R=301,L]
RewriteRule ^shop/(.*)$ http://www.example.com/$1 [R=301,L]

# Canonical Redirect to www.example.com
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

# SSU Rewrite
RewriteCond %{REQUEST_URI} !\.(jpe?g|gif|png|css|js|zip)$
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 [E=VAR1:$1,QSA]

Every change is important, right down to the last slash and dot.

13 Jun 2010, 12:06 PM
#7
bobthemolder avatar

bobthemolder

Zen Follower

Join Date:
Nov 2008
Posts:
164
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

g1smd:

Rule order optimised, added escaping in patterns, added non-www to www canonicalisation, and rewrite re-coded for better server efficiency:

SSU SetUp

Options +FollowSymLinks -MultiViews
RewriteEngine On

Deny access to .htaccess

RewriteRule ^.htaccess$ - [F]

The "/" is the default value so remove the following line

RewriteBase /

Custom Redirects

RewriteRule ^index.html$ http://www.example.com/ [R=301,L]
RewriteRule ^shop/CategoryB$ http://www.example.com/CategoryC [R=301,L]
RewriteRule ^shop/CategoryB/CategoryB-(.)$ http://www.example.com/CategoryC/CategoryC-$1 [R=301,L]
RewriteRule ^shop(/index.html)?$ http://www.example.com/shop/ [R=301,L]
RewriteRule ^shop/(.
)$ http://www.example.com/$1 [R=301,L]

Canonical Redirect to www.example.com

RewriteCond %{HTTP_HOST} !^(www.example.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

SSU Rewrite

RewriteCond %{REQUEST_URI} !.(jpe?g|gif|png|css|js|zip)$
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*) index.php?/$1 [E=VAR1:$1,QSA]

> 
> Every change is important, right down to the last slash and dot.
Wow :clap:

So, I should remove the: "RewriteBase"?

On the following line, should it not re-direct to the mainsite instead of the /shop/ folder, since I moved the store out of that directory to the main folder?
13 Jun 2010, 4:49 PM
#8
g1smd avatar

g1smd

Zen Follower

Join Date:
Mar 2010
Location:
UK
Posts:
449
Plugin Contributions:
0

Re: Odd Category Redirect - using SSU

If this .htaccess file is placed in the root folder of your domain, it will redirect requests for files in the /shop/ folder to the same remainder path and filename (apart for the explicit coded exceptions), but in the root of the domain. Nothing in the code I supplied redirects to the /shop/ folder.

To be clear, in a RewriteRule the Regular Expression pattern (on the left) is tested for a match with the requested URL specified in the literal GET /shop/somefile HTTP/1.1 request coming from the browser.

The literal target (on the right) should be a full protocol+domain+path if the rule is a redirect. In that case the [R=301,L] flags should be added. If the literal target is without protocol and without domain and used only with the [L] flag then the result is an internal rewrite of the incoming URL request to a non-default internal filepath inside the server.