Posted - 11/09/2014 : 23:33:00
SEO Friendly URLs – Lessons Learned
The following lessons learned were based on work using ECT V6.4. Working with Andy and Vince there are some modifications to the setup instructions if your store software is not at the domain root. For example, if you have a store at http://www.mydomain.com/store or if you are setting things up on a development computer. These notes were developed while working with the PHP version of the software.
If the software is used at a store that is at the root of the domain then the instructions probably work as provided. However, there are three situations where the instructions need to be modified.
The first issue that I’ve found is that the ECT software is using the server name instead of the store URL (or the $$orstoreurl variable in the includes.php file if it is set) for its SEO friendly URL processing. This is why I believe it works fine if your store is at the top of the domain (www.mystore.com). However, the three conditions that I’ve found where the instructions need to be modified to work are:
1. If you have your store at one or more levels below your top domain (www.mydomain.com/store) 2. If you use a test folder below your main store domain to test an update before putting on the live site (www.mystore.com/test) 3. If you use a development computer to test updates, make mods, etc. (this was the case that started this thread for me). In my case I am running Windows 7 Pro 64-bit with Apache, MySQL and PHP installed. In this configuration I have my server at www.myserver.dev and then I have a separate folder for each of my projects (e.g. www.myserver.dev/store, www.myserver.dev/blog, www.myserver.dev/church)
Since Version 6.4 appears to be using the server name you will need to have some files set up for your test environment and then modify them for the live environment. Specifically the files that are different between your test environment or development environment and your production site are:
1. Where ever you have <base href=…> defined,. In my case I found that by putting in Dreamweaver’s template file (document.dwt) so that it is automatically included on every page is the easiest because my client has several static URLs for some of her categories. This actually isn’t a limitation of Version 6.4, but it is something you need to be aware of. 2. Includes.php 3. .htaccess.
For the <base href=…> issue a little PHP code will allow you to pull the store URL out of the database and use it to create the actual <base href=…” declaration on the fly - that's something that is still on my list of things to do.
Now for the changes to the includes.php file. The first thing that I learned is that if you use a test directory below the store domain (www.mystore.com/test or www.mydomain.com/store/test) then you’ll need to set the variable $orstoreurl to specify your store URL test folder. So $orstoreurl=”http://www.mystore.com/test” or $orstoreurl=”http://www.mydomain.com/store/test”. Before you deploy the includes.php file to your live store site you will want to comment out or remove the $orstoreurl variable declaration.
The next change to the instructions for the changes to includes.php are the SEO patterns ($seocaturlpattern, $seoprodurlpattern and $seomanufacturerpattern). If you store is not at the root of the domain then you need to add the path below the root of the domain to where your store is. For example, on my development computer the top domain (server name) is www.myserver.dev and the store environment is at www.myserver.dev/store so $seocaturlpattern="/store/category/%s";, $seoprodurlpattern="/store/product/%s"; and $seomanufacturerpattern="/store/manufacturer/%s";. This format applies to you if you have your store below the top domain of your live site. For example, if your store is at www.mydomain.com/store then you would use the same patterns shown above. If you are running a test folder below your store’s main URL then you would use $seoprodurlpattern=”/test/product%s”;. Before moving the includes.php file from your test environment to the live store site these patterns will have to change to reflect the live store.
Finally, for the .htaccess file this is less of a hassle because once written it won’t need to change (just make sure you don't upload your .htaccess file from your development environment if it is different than you live store). If your store is at the top of the domain then the instructions should work. If your store is below the top domain then you’ll need to add the subfolder path to your store’s test environment or actual operating environment. If you are using a test folder on your store’s live site then you will need to modify the rewrite rules to include the test site. For example, RewriteRule ^category/([^/.]*)/?$ test/categories.php?cat=$1 [QSA,nc,L,B]. Use of “test/” will also be needed for the product, manufacturer and proddetail rewrite rules.
I hope you find this useful, David M.
|