Rewrite away PC's sub-directories |
Post Reply | Page 123> |
Author | |
Guests
Guest |
Post Options
Thanks(0)
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:
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 |
|
blackey
Newbie Joined: 11-November-2008 Location: Livermore, CA Status: Offline Points: 0 |
Post Options
Thanks(0)
|
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 |
|
blackey
Newbie Joined: 11-November-2008 Location: Livermore, CA Status: Offline Points: 0 |
Post Options
Thanks(0)
|
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.
Edited by blackey - 31-January-2010 at 2:25pm |
|
Guests
Guest |
Post Options
Thanks(0)
|
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.
|
|
whizzinpc
Newbie Joined: 17-January-2006 Location: California Status: Offline Points: 20 |
Post Options
Thanks(0)
|
Great Stuff Guys! Wish this was here a year ago before we did our url changes to the 404 method.
|
|
Guests
Guest |
Post Options
Thanks(0)
|
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. |
|
blackey
Newbie Joined: 11-November-2008 Location: Livermore, CA Status: Offline Points: 0 |
Post Options
Thanks(0)
|
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 |
|
Guests
Guest |
Post Options
Thanks(0)
|
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.
|
|
blackey
Newbie Joined: 11-November-2008 Location: Livermore, CA Status: Offline Points: 0 |
Post Options
Thanks(0)
|
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.
|
|
Guests
Guest |
Post Options
Thanks(0)
|
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? |
|
Post Reply | Page 123> |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |