View Full Version : Mod rewrite tutorial?
Anyone willing to share how his is done with this software. my server does allow this.
This is one of the most important things i tink with getting indexed.
theres lots of posts on it but nobody reall sharing just pointing to google to search. tis is fine but may not work on this script.
I have to admit, for everything i've been able to achieve with my shopwindow, modrewrite isn't one of them, as i'm not so good at working with .htaccess so everytime I try I break something.
I too would love someone to share their success at getting spider friendly urls in place for this, as I know a few people have managed to do it.
Although strictly speaking, I think it is something tat ShopWindows should actually have set up for us as default too.
Anyway, one of you good people who've managed to do it, please share an easy to use guide to doing it.
I know i've tried the bits that have been posted on that other thread and thank the people that shared their tips, but I did not manage to do it from them and would greaty appreciate further assistance with achieving it.
It has been done by others and i think it would be nice gesture to show how they done it.
As i say if you have sef url's your in with a better chance in the serps.
Maybe thats why ppl aint sharing it lol.
IntroSites
01-03-08, 12:46
mine is not perfect and all i done was use regular expressions to rewrite the urls on the fly, just buffered the output and run the expressions on the buffer before output, it doesnt really touch the sw files.
Its rough but works.
mine is not perfect and all i done was use regular expressions to rewrite the urls on the fly, just buffered the output and run the expressions on the buffer before output, it doesnt really touch the sw files.
Its rough but works.
Can you show us how you did this so we can implement it ourselves if possible.
Thanks
okay,
As i say if you have sef url's your in with a better chance in the serps.
Maybe thats why ppl aint sharing it lol.
yep! you guessed it.
Don't take this the wrong way, but some people have played for months to achieve what they have. If they were to suddenly hand it over, they'd be competing with everyone.
mod rewrite isn't an unfair advantage, it's a nessecary skill we all have to learn in order to achieve better results online, not just with shopWindow.
here's some essential reading:
http://corz.org/serv/tricks/htaccess.php
http://corz.org/serv/tricks/htaccess2.php
I learnt everything I know about .htaccess from cor
Never met him, but he's not adverse to the ODD email now and again when you get really stuck.
he likes beer and has a donate button top right of his advert free site.
Some of my tips for SW rewrite:
for simple "Lets get rid of the get strings" type rewrite:
open your output files and str_replace("&Var=", "-Var-", $str); for all get values.
Str_replace(".php", "", $fileName); for your filenames too.
for slightly more advanced rewrite (prodnames in urls)
dont rely on the htaccess for URL formatting or do the str_replace above. get deep within SW (includes/classes/shopCore.php) and format your links there with a [PRODNAME] marker. in the output files: str_replace("[PRODNAME], "This Product Name", $str);
if you want full modrwritten category/productname.html
forget it until you've mastered the above
specific questions such as "What's the regex to allow all alphanumeric characters" or " .html$ or .html ?" will get answered. We're here to help but you've got to do it yourself.
Exelent links andy great resurce now to do some readig on this.
cheers
Confuscius
02-03-08, 00:36
You do not have to mod rewrite to make SW work in the search engines but if you leave the shop as it is then you are probably one of the 99% who think if they stick it up then they will be retired before they know it.
Andy's advice is spot on, one step at a time and one day you may well have a fully mod rewritten text version but expect about a week to achieve that AFTER you understand mod rewrite and all of the structure of SW, simple rewriting will take a couple of days.
If you are like me then even if I gave you the mod rewrite files then I would also have to give you the other 100 or so changes that I have made to the functionality to make it different to fit in with my mod rewrite. I am currently trying to assess if mod rewrite makes that much difference in the SERPS - my gut feeling is that what you do on the page and off the site is far more important. ;)
Paul
Andy
Thanks - good links,
hope this may be of some help to someone
.htaccess has got
DirectoryIndex index.php
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteRule corner-sofa search.php?c=449&q=corner+sofa&iListLimit=10&sListSort=hi [nc]
note - the RewriteRule is one line only
this gives the required results for both
http://pricecompareuk.com/corner-sofa
http://pricecompareuk.com/home-garden/furniture/sofas/corner-sofa/ref=1
Andy, thanks for the hints so far.
I'm making progress on getting static urls working. (not with the keywords, but first step first hey!)
Can you point me in the general direction of the listoffset area in the output files?
Thanks
The Output files tend to be in includes/elements/
if you're working on the product listings, then it'll be product_display_list.php
Have a look through that file and find all instances of "require" or "include" and look at the files that are being included.
You should see that nav_product_list.php is included somewhere.
This file gnerates the << prev and next >> links, the counter (showing X products out of XXXX available) and the pagination at the bottom.
'Tis where thou shalt findeth thy desired ilistoffset code. :D
The best way to find where each bit of php code resides in any CMS is to start at the beginning. You know you're looking at a category.php page (because of the URL), so open that file, check the includes, then check their includes.
okay,
yep! you guessed it.
Don't take this the wrong way, but some people have played for months to achieve what they have. If they were to suddenly hand it over, they'd be competing with everyone.
mod rewrite isn't an unfair advantage, it's a nessecary skill we all have to learn in order to achieve better results online, not just with shopWindow.
here's some essential reading:
http://corz.org/serv/tricks/htaccess.php
http://corz.org/serv/tricks/htaccess2.php
I learnt everything I know about .htaccess from cor
Never met him, but he's not adverse to the ODD email now and again when you get really stuck.
he likes beer and has a donate button top right of his advert free site.
Some of my tips for SW rewrite:
for simple "Lets get rid of the get strings" type rewrite:
open your output files and str_replace("&Var=", "-Var-", $str); for all get values.
Str_replace(".php", "", $fileName); for your filenames too.
for slightly more advanced rewrite (prodnames in urls)
dont rely on the htaccess for URL formatting or do the str_replace above. get deep within SW (includes/classes/shopCore.php) and format your links there with a [PRODNAME] marker. in the output files: str_replace("[PRODNAME], "This Product Name", $str);
if you want full modrwritten category/productname.html
forget it until you've mastered the above
specific questions such as "What's the regex to allow all alphanumeric characters" or " .html$ or .html ?" will get answered. We're here to help but you've got to do it yourself.
Hi Andy,
I've been reading this quite carefully and been trying to follow the prodname in url without much success would you mind giving me a bit of a more detailed explanation and a few pointers.
regards
Pete
I got my website based on client software mod re-written to a certain extent, I cannot however get to resolve navigation, if someone could provide assistance, it would be much appreciated. I have tried various techniques, but all messed up.
I have my productlist for searches display as mysite.com/productlist.php?q=searchterm and productlist for categories display as mysite.com/categoryname_1.htm
I want produclist for categories to have a navigation of mysite.com/categoryname_1/10, mysite.com/categoryname_1/20 etc as opposed to the present http://www.mysite.com/productlist.php?rb=4-5&iListOffset=30
I have spent hours trying to resolve this but lack of knowhow has let me down. Looking forward to assistance.
I am assuming the following:
/categoryname_1/20
"categoryname" will be dynamically filled based on the actual category name
"1" is the Category ID
"20" is the iListOffset
as such:
RewriteRule ^([^/]+)_([0-9]+)/([0-9]+)$ /productlist.php?rb=4-$2&iListOffset=$3 [L]
Should do.
I am assuming the following:
/categoryname_1/20
"categoryname" will be dynamically filled based on the actual category name
"1" is the Category ID
"20" is the iListOffset
as such:
RewriteRule ^([^/]+)_([0-9]+)/([0-9]+)$ /productlist.php?rb=4-$2&iListOffset=$3 [L]
Should do.
Hi Andy,
Thanks for your help. What I am actually after is instructions to edit the nav_product_list file to give navigation in the form mysite.com/categoryname_4-98/1, mysite.com/categoryname_4-98/2 etc for categories and mysite.com/search+term/1, mysite.com/search+term/2 etc for searches.
Presently I have my site mod rewritten, base product list for categories take the form of mysite.com/categoryname_4-98 but navigation is in its original form.
Your tips would be much appreciated. I presume its something to do with these codes:
if (strlen($sPageQuery)>0) {
$sPageUrl= $sCurrentPage.'?'.$sPageQuery.'&iListOffset=';
}
else {
$sPageUrl= $sCurrentPage.'?iListOffset=';
}
Ah ok, it's php you want.
Top of my head stuff cos I'm away from my office right now:
open the file and look for any variable that resembles a link (and I think there's alot of them). $sPageUrl and $sCurrentPage rings a bell.
Just rebuild the link variable using your rewrite formatting.
if I remember correctly, nav_product_list wasn't the hardest to mess with, it was doing the Breadcrumbs. In V1 I gave up and took the links out of them instead.