ProductCart E-Commerce Solutions Homepage
Forum Home Forum Home > ProductCart > Search Engine Optimization
  New Posts New Posts RSS Feed - Rewrite away PC's sub-directories
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Rewrite away PC's sub-directories

 Post Reply Post Reply Page  123>
Author
Message
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Topic: Rewrite away PC's sub-directories
    Posted: 30-January-2010 at 1:27am
I've been working on this on an off for far too long, but as any of you who may work with regex and ISAPI_Rewite know, it's not easy to nail things down . . . even the folks at Helicon typically have to make several trial and error attempts to get things right.

So, I am really happy to announce that with a mere 5 lines of conditions/rules we've successfully "rewritten away" the top two sub-directories PC enforces so that all of your site content resolves to the web root!Some developers may find it desirable not to have to use these two sub-directories and would rather have the store resolved right in the web root of the domain.

However, to do this, you must have a host that provides Helicon's ISAPI_Rewrite (which is awesome for lots of other issues too) -- so you must have a VPS or dedicated server plan where you can install things on the server yourself, such as ISAPI_Rewrite. Shared hosting plans are not likely to offer this option unless you are with a "boutique" host such as Grey Beard Design Group or Web Merchant Services.

If you have the option to use ISAPI_Rewrite, here is the code you will want to use in your .htaccess or httpd.ini file in your web root:

# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.42

RewriteEngine on
RewriteBase /

# START: Mask the /productcart/pc/ directory structure and make all such URLs look like they are in the web root
# Handle image directories as they are otherwise referenced from the web root:
RewriteRule ^(images/.*|catalog/.*)$ productcart/pc/$1 [NC,L]
RewriteRule ^(UPSLicense/.*|CAPTCHA/.*)$ productcart/$1 [NC,L]

# Handle javascrits as they are otherwise reference above the web root:
RewriteRule ^(includes/.*)$ productcart/$1 [NC,L]

# Handle objects called via ../pc/ when already in the /pc/ folder:
RewriteRule ^pc/(.*)$ productcart/pc/$1 [NC,L]

# Permanently redirect all pages that were using subdirectories:
RewriteRule ^productcart/pc/(.*)$ $1 [NE,NC,R=301,L]

# Handle having all pages resolve in the web root without subdirectories:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ productcart/pc/$1 [NC,L]
# END: Mask the /productcart/pc/ directory structure and make all such URLs look like they are in the web root

What's more, if you would find it desirable to maintain the first sub-directory as a way of adding some key word relevance to your URLs, the script can be easily adapted to provide for that.

Finally, it's possible that you may have customized some things in your design differently than this set up rules will handle. If that is the case you should maybe be able to follow the example above, but if not and you have trouble with the regex, please PM me.

PS: This post is not intended to make any claim that rewriting away the sub-directories would improve SEO. The options here are provided as just that: options so that you can make your own decisions on how best to SEOptimize your store.
 

EDIT: Correct for v4 One Page Checkout -- added handling for the JQuery and Spry subdirectories.

EDIT: Simplified rules for the previous edit -- should have just done it like this in the first place, LOL!

EDIT: Just confirmed that this full set of conditions and rules will NOT work with versions of ISAPI_Rewrite prior to 3.1.0.43. Curent version as of 02/12/2010 is 3.1.0.69

EDIT: Fixed a minor wrinkle with location of UPS logo in v4 OPC

EDIT: Fixed a minor wrinkle with location of CAPTCHA images

EDIT: Simplified the conditions to anything that gets put into the /productcart/includes/ folder

EDIT: Added fix introduced by v4.1 calling objects by ../pc/ when already in the /pc/ folder


Edited by Sean@WMS - 23-September-2010 at 6:08pm
Back to Top
blackey View Drop Down
Newbie
Newbie


Joined: 11-November-2008
Location: Livermore, CA
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote blackey Quote  Post ReplyReply Direct Link To This Post Posted: 31-January-2010 at 1:42pm
Sean,

Very, Very cool.  Does not seem to work with 4.0 checkout though.  Worked on all the pages and cart, but the onepagecheckout.asp page would not allow me to check in.

Thoughts?

Bill
Back to Top
blackey View Drop Down
Newbie
Newbie


Joined: 11-November-2008
Location: Livermore, CA
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote blackey Quote  Post ReplyReply Direct Link To This Post Posted: 31-January-2010 at 2:00pm
If you could have this ignore https pages, I think it would work with the checkout.  I tried it with the https off, and that works fine.  Not sure if the code below is the most elegant, but it works. 

I think having the checkout not rewriten is a good idea anyway.  That way everyone's Analytics will not need to be re-written, etc...  Plus search engines shouldn't spider those pages anyways.

The cannonical link can be easily modified to not return the directories.




# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.42

RewriteEngine on
RewriteBase /

# START: Mask the /productcart/pc/ directory structure and make all such URLs look like they are in the web root
# Handle image directories as they are otherwise referenced from the web root:

RewriteCond %{HTTPS} off
RewriteRule ^(images/.*|catalog/.*)$ productcart/pc/$1 [NC,L]

# Handle javascrits as they are otherwise referenced above the web root:
RewriteCond %{HTTPS} off
RewriteRule ^(includes/javascripts/.*)$ productcart/$1 [NC,L]

# Permanently redirect all pages that were using sub-directories:
RewriteCond %{HTTPS} off
RewriteRule ^productcart/pc/(.*)$ $1 [NC,R=301]

# Handle having all pages resolve in the web root without sub-directories:
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)$ productcart/pc/$1 [NC,L]
# END: Mask the /productcart/pc/ directory structure and make all such URLs look like they are in the web root



Edited by blackey - 31-January-2010 at 2:25pm
Back to Top
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Posted: 01-February-2010 at 2:16pm
Hi Bill,
 
I see I needed to add handling for the JQuery and Spry directories used in the OPC. I've edited the original post to handle that.
 
This would probably be the way to go for new stores, but I hear what you are saying about existing stores wanting to switch this up. Your solution, to condition out HTTPS would be the way to go there.
Back to Top
whizzinpc View Drop Down
Newbie
Newbie
Avatar

Joined: 17-January-2006
Location: California
Status: Offline
Points: 20
Post Options Post Options   Thanks (0) Thanks(0)   Quote whizzinpc Quote  Post ReplyReply Direct Link To This Post Posted: 01-February-2010 at 7:42pm
Great Stuff Guys! Wish this was here a year ago before we did our url changes to the 404 method.
Back to Top
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Posted: 01-February-2010 at 9:14pm
Thanks, @whizzinpc, but just to be clear to everyone, this has nothing to do with PC's 404-based URL rewriting. That rewriting handles "pretty" URLs rather than the default query string based URLs.

This is a different level of rewriting to mitigate against the two top level sub-directories. It changes nothing about whether the page level is query string based or bounced of the custom 404 error handling method.
Back to Top
blackey View Drop Down
Newbie
Newbie


Joined: 11-November-2008
Location: Livermore, CA
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote blackey Quote  Post ReplyReply Direct Link To This Post Posted: 06-February-2010 at 8:25pm
Sean,

I've been implementing this and have found Google indexing the following:

www.lpiracing.com/store/pc/store/pc

It's rewriting the store/pc and removing it, but if there are multiples it removes all of them.  I'd like this to return a 404.  I've been trying to figure out how to keep it form doing this, but so far it's eluding me.




Edited by blackey - 06-February-2010 at 8:26pm
Back to Top
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Posted: 06-February-2010 at 9:37pm
Hi @blackey,
 
I'm afraid I don't quite understand you question. Are you saying that you have a directory structure with www.lpiracing.com/racing-parts/pc/ as well as www.lpiracing.com/racing-parts/pc/racing-parts/pc/ -- or that somehow Google indexed things this way?
 
Had a spin through your site, clicking from pages Google had indexed and everything appear to be all good.
 
Please explain further what you are up against here.
Back to Top
blackey View Drop Down
Newbie
Newbie


Joined: 11-November-2008
Location: Livermore, CA
Status: Offline
Points: 0
Post Options Post Options   Thanks (0) Thanks(0)   Quote blackey Quote  Post ReplyReply Direct Link To This Post Posted: 07-February-2010 at 11:19am
Yea sorry about that.  The real directory is store/pc.  Unfortunately, store/pc/store/pc will rewrite to the same page.  Google has picked up on Store/pc/store/pc and I've seen some pages being spidered that way.
Back to Top
Guests View Drop Down
Guest
Guest
Post Options Post Options   Thanks (0) Thanks(0)   Quote Guests Quote  Post ReplyReply Direct Link To This Post Posted: 08-February-2010 at 1:30pm

So, are you saying that you want to use this to rewrite /store/pc/store/pc/ back to just /store/pc/ and not have the pages re-written back to the web root?

Back to Top
 Post Reply Post Reply Page  123>
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.043 seconds.