Google Optimization
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
Go Back   SEO Chat ForumsGoogleGoogle Optimization

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread SEO Chat Forums Sponsor:
  #1  
Old September 6th, 2008, 07:44 AM
Joppiesaus Joppiesaus is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 59 Joppiesaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 40 m 56 sec
Reputation Power: 1
URL rewriting (?)

Hello,

To make my upcoming website seo friendly I want to implement some URL rewriting (I guess, if someone knows a better solution to the following please let me know).

The website is a webshop with a lot of different products. The website is in php so normally I would write my product pages something like this:

mysitedotcom/product.php?ID=100&Categorie=Hat&Subcategorie=Red%20Hat&Name=Superflex%20Red%20Hat

All the information for the different Categorie, Subcategorie and Name would be pulled from a MYSQL database. What I want to do is make the URL like this:

mysitedotcom/Hat/Red-Hat/Superflex-Red-Hat.html

So what I need is:
- PHP must become .HTML
- Database fields must be used to make a "tree" in the URL (--> /.../...)
- ID should not be visible because this doesn't say anything about the product
- I want "- " implemented for spaces so that the internet explorer doen't give the standard "%20"

How do I do this? Also, I do not want to link from one page to "mysitedotcom/product.php?ID=100&Categorie=Hat&Subcategorie=Red%20Hat&Name=Superflex%20Red%20Hat" where it rewrites to "mysitedotcom/Hat/Red-Hat/Superflex-Red-Hat.html" on that page. In fact, I don't want this contruction (mysitedotcom/product.php?ID=100&Categorie=Hat&Subcategorie=Red%20Hat&Name=Superflex%20Red%20Hat) visible anywhere in my website code for Google to see.

How do I pull this off and can this be done using Dreamweaver. I guess this is quite a request, if u need more info, please let me know. I do know a website who does this very well (www dot klara dot nl !!! not so suitable for work however) They do this in not only their productpages, but also their category and subcategory pages, which is exactly what I want to do.

Many thanks in advance!

Reply With Quote
  #2  
Old September 6th, 2008, 09:01 AM
s1974lee's Avatar
s1974lee s1974lee is offline
Black Panther
SEO Chat Newbie (0 - 499 posts)
 
Join Date: May 2006
Location: Leeds
Posts: 62 s1974lee User rank is Just a Lowly Private (1 - 20 Reputation Level)  Folding Points: 59510 Folding Title: Beginner FolderFolding Points: 59510 Folding Title: Beginner FolderFolding Points: 59510 Folding Title: Beginner Folder
Time spent in forums: 1 Day 4 h 54 m 22 sec
Reputation Power: 4
Send a message via Google Talk to s1974lee Send a message via Skype to s1974lee
Here is a useful toolto help you http://www.seochat.com/seo-tools/url-rewriting/
__________________
Just 'Chroming' the Web



Market Defender

Reply With Quote
  #3  
Old September 6th, 2008, 10:32 AM
ssandecki's Avatar
ssandecki ssandecki is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Location: Chicago, IL
Posts: 120 ssandecki User rank is Corporal (100 - 500 Reputation Level)ssandecki User rank is Corporal (100 - 500 Reputation Level)ssandecki User rank is Corporal (100 - 500 Reputation Level)ssandecki User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 9 h 23 m 50 sec
Reputation Power: 3
Send a message via MSN to ssandecki
This will require "alot" a work most likely, and require editing of your webshops backend. Here is an idea, you should search your webshops website to see if any mods\addons exist already to create SEO friendly URLs, if not you might want to hire a freelance to do this work for you, I highly doubt anyone will go beyond linking you to apache url modding resources.

Reply With Quote
  #4  
Old September 6th, 2008, 10:52 AM
Joppiesaus Joppiesaus is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 59 Joppiesaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 40 m 56 sec
Reputation Power: 1
Quote:
Originally Posted by ssandecki
This will require "alot" a work most likely, and require editing of your webshops backend. Here is an idea, you should search your webshops website to see if any mods\addons exist already to create SEO friendly URLs, if not you might want to hire a freelance to do this work for you, I highly doubt anyone will go beyond linking you to apache url modding resources.


The thing is that this website still needs to be build and I want to do it right the first time. So, I can really still do anything.... I'll have a look around, but if anyone here has some experience or really solid suggestions I would love to hear them.

kind regards.

Reply With Quote
  #5  
Old September 6th, 2008, 11:23 AM
ssandecki's Avatar
ssandecki ssandecki is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Location: Chicago, IL
Posts: 120 ssandecki User rank is Corporal (100 - 500 Reputation Level)ssandecki User rank is Corporal (100 - 500 Reputation Level)ssandecki User rank is Corporal (100 - 500 Reputation Level)ssandecki User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 9 h 23 m 50 sec
Reputation Power: 3
Send a message via MSN to ssandecki
Quote:
Originally Posted by Joppiesaus
The thing is that this website still needs to be build and I want to do it right the first time. So, I can really still do anything.... I'll have a look around, but if anyone here has some experience or really solid suggestions I would love to hear them.

kind regards.


I would take a look at ZenCart and OSCommerce then for your backend.

Reply With Quote
  #6  
Old September 6th, 2008, 01:46 PM
abercrombie abercrombie is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 3 abercrombie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 23 m 40 sec
Reputation Power: 0
depending on what software you use for your website, i would suggest looking for any SEO plugins. most major php software suites have SEO modifications or plugins. doing this task yourself is daunting.

Reply With Quote
  #7  
Old September 7th, 2008, 06:48 AM
Joppiesaus Joppiesaus is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 59 Joppiesaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 40 m 56 sec
Reputation Power: 1
Quote:
Originally Posted by abercrombie
depending on what software you use for your website, i would suggest looking for any SEO plugins. most major php software suites have SEO modifications or plugins. doing this task yourself is daunting.


I agree, I have thought about the things I would need to do to implement this troughout the site. The problem of rewriting the URL for product pages does not seem to be the biggest problem, however, I also want to link directly to the correct link obviously (so this isn't rewriting anymore is it?) and how on earth do websites like i mentioned get the right data for their product page? I always used a GET method where the product ID was in the URL, but this isn't possible using link building like this...

If anyone has experience making these websites and can tell me what the best software is for doing this job (prefferebly free software as I do not have a large amount of money to invest) please let me know.

If you could also tell me how the mechanics of websites like www dot klara dot nl work (NSFW!) (Sorry, is one of the only websites I know who really did the job well implementing good links) please let me know, I am VERY interested of implementing this idea the correct way when I start!

Thanks.

Reply With Quote
  #8  
Old September 7th, 2008, 10:49 AM
graphical_force's Avatar
graphical_force graphical_force is offline
Student of Life
SEO Chat Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 133 graphical_force User rank is Corporal (100 - 500 Reputation Level)graphical_force User rank is Corporal (100 - 500 Reputation Level)graphical_force User rank is Corporal (100 - 500 Reputation Level)graphical_force User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 13 h 21 m 2 sec
Reputation Power: 3
What you are talking about depends on what is the platform of your server. If you are using php it is most likely Apache (linux). If so, then you would use mod_rewrite. I was in the same situation for a IIS (windows) server and there are products for that that are different. Find out some info on your server first and post back.
__________________
A sig test:

castrol srf | Graphical Force

"When everybody is special . . . nobody will be." -Syndrome

Reply With Quote
  #9  
Old September 7th, 2008, 11:39 AM
Joppiesaus Joppiesaus is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 59 Joppiesaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 40 m 56 sec
Reputation Power: 1
Quote:
Originally Posted by graphical_force
What you are talking about depends on what is the platform of your server. If you are using php it is most likely Apache (linux). If so, then you would use mod_rewrite. I was in the same situation for a IIS (windows) server and there are products for that that are different. Find out some info on your server first and post back.


I am currently looking for a linux based server. However, I am very flexible on this one because I have worked on both in the past for small webshops. (So if windows is easier I could look at that as well..)

Reply With Quote
  #10  
Old September 7th, 2008, 12:27 PM
Joppiesaus Joppiesaus is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 59 Joppiesaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 40 m 56 sec
Reputation Power: 1
Quote:
Originally Posted by s1974lee
Here is a useful toolto help you http://www.seochat.com/seo-tools/url-rewriting/


Hi, Thanks for the tool, it seems quite handy, but doesn't this leave me with a lot of problems?

For instance, when I link page 1 to the dynamic page, doesnt the original link still apply on page 1? So wouldn't this be the case: on page 1 this link: mysite dot com/product.php?id=1&name=Example would link to the rewritten dynamic page mysite dot com/product/ID/1/Name/Example/ ????

If the 'linking URL' in the code would also be converted then this would help a lot.

Reply With Quote
  #11  
Old September 8th, 2008, 03:29 AM
s1974lee's Avatar
s1974lee s1974lee is offline
Black Panther
SEO Chat Newbie (0 - 499 posts)
 
Join Date: May 2006
Location: Leeds
Posts: 62 s1974lee User rank is Just a Lowly Private (1 - 20 Reputation Level)  Folding Points: 59510 Folding Title: Beginner FolderFolding Points: 59510 Folding Title: Beginner FolderFolding Points: 59510 Folding Title: Beginner Folder
Time spent in forums: 1 Day 4 h 54 m 22 sec
Reputation Power: 4
Send a message via Google Talk to s1974lee Send a message via Skype to s1974lee
Quote:
Originally Posted by Joppiesaus
Hi, Thanks for the tool, it seems quite handy, but doesn't this leave me with a lot of problems?

For instance, when I link page 1 to the dynamic page, doesnt the original link still apply on page 1? So wouldn't this be the case: on page 1 this link: mysite dot com/product.php?id=1&name=Example would link to the rewritten dynamic page mysite dot com/product/ID/1/Name/Example/ ????

If the 'linking URL' in the code would also be converted then this would help a lot.


I would suggest using 301 redirects on your original URL's to your new URL's.

Reply With Quote
  #12  
Old September 8th, 2008, 08:36 AM
sksingh sksingh is offline
Registered User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 20 sksingh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 14 m 50 sec
Reputation Power: 0
Hello Joppiesaus,

There is 2 way for URL Rewriting.

One is to using POST on the place of GET.

And another is by Apache URL Rewriting.

you can see it on this location:

httpddotapachedotorgslashdocsslash1dot3slashmiscsl ashrewriteguidedothtml

Reply With Quote
  #13  
Old September 8th, 2008, 09:22 AM
JagNet's Avatar
JagNet JagNet is offline
Smoke me a kipper...
SEO Chat Regular (2000 - 2499 posts)
 
Join Date: Aug 2007
Posts: 2,487 JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 3 h 37 m 22 sec
Reputation Power: 63
Implementing mod_rewrite in the manner you've suggested is involved, but taken step by step it shouldn't be that daunting.

First thing is to take a look at the .htaccess rules, eg.
Code:
RewriteRule ^/(.*)/(.*)/(.*)\.html$ /product.php?Categorie=$1&Subcategorie=$2&Name=$3


Here you can see that we pass 3 variables, split by forward slashes, to the script: Categorie, Subcategorie, and Name. As you've already mentioned, the ID variable is no longer present, so that rules out the ability to fetch the required product from the database according to its ID number. Instead you need to look at what other variable you can use. In the case above that would be Name. It's still not ideal though, as in a larger shop there's plenty of opportunity to have more than one product with the same name. Secondly, you'd need to replace hyphens with spaces via php before calling the database, but what if the product name has hyphens in it? Too much possibility for error for my liking.

What to do then? My personal preference would be to introduce a new variable: Slug. This would be stored as a seperate, indexed column in the database, and would equate to the pseudo filename, avoiding any escaped characters. In your example URL ( /Hat/Red-Hat/Superflex-Red-Hat.html ), Slug would be "Superflex-Red-Hat".

So, instead of searching the database for $_GET['ID'], you'd be searching for $_GET['Slug'] (sanitizing the input of course).

The .htaccess code would then be something like:
Code:
RewriteRule ^/(.*)/(.*)/(.*)\.html$ /product.php?Categorie=$1&Subcategorie=$2&Slug=$3


Constructing the URL

The next step would be to create a function to construct the URL to maintain consistancy, eg

php Code:
Original - php Code
  1. function writeUrl($productSlug,$cat = false, $subCat = false) {
  2.   $url = '/';
  3.   if (!empty($cat)) {
  4.     $url .= $cat .'/';
  5.   }
  6.  
  7.   if (!empty($subCat)) {
  8.     $url .= $subCat .'/';
  9.   }
  10.   $url .= $productSlug . '.html';
  11.   return $url;
  12. }


So, in product category lists for example:
php Code:
Original - php Code
  1.  
  2.   while ($f = $res->FetchRow()) {
  3.     echo '<a href="' . writeUrl($f['slug'],$cat,$subCat) .'">' . $f['product_name'] . '</a>';
  4.   }


301 redirects

You also need to ensure that the old style URLs are no longer available. The easiest way is to check for the value of $_SERVER['REQUEST_URI']
If a '?' is present it's an old style one, and so retrieve the data, pass it through the writeUrl() function, and redirect.

By checking for old-style URLs it does at least mean that missing a hard-coded URL somewhere in your site isn't going to lead to duplicate pages.

I would also implement a check for the categories. If you happen to move the product to a different category, the URL would still work if you were just searching the database for $_GET['Slug'].

Perhaps even consider removing the categories from the URL altogether. That way it may be possible to remove some database requests for category data just to construct the URL (speeding up the site), and should you decide to change categories you don't have to change the URL as well (providing long term URL stability).



Without seeing the existing code for your site I can't really be any more precise, but it should at least give you some food for thought.
Comments on this post
johnafrankllin agrees!
__________________
... I'll be back for breakfast
New to SEO? SEOChat SEO FAQs
Forum Rules and Posting Guidelines
URL canonicalization code solutions
Vigorously pursuing the floccinaucinihilipilification of cheap SEO tricks

Reply With Quote
  #14  
Old September 9th, 2008, 02:20 PM
Joppiesaus Joppiesaus is offline
Contributing User
SEO Chat Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 59 Joppiesaus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 h 40 m 56 sec
Reputation Power: 1
Absolutely great how you are able to make this clear to me, a marketing dude with only some basic knowledge on php and very very basic knowledge on mod rewriting. You have my thanks!

1: The .htaccess line seems very logical. You "rename" the variables into variable $1 etc so they are easy to work with.

2: If I understand you correctly, the slug varibale has to be added manually in the database for each product that is added? So I manually will add hyphens to the product name if necessary and no errors can occur because it is manually added and it does not need to be rewritten in any way (comparable to the ID variable, only the slug variable says something about the product which is better for SEO reasons)...?

constructing the URL

3.a: I am not exacly sure what this php function does (this has to be implemented on every page in the website right? (or at least included via a different 'functions page'?)), but i guess it just builds up the URL when the 3 variables are found in a dynamic URL.

3.b: does this php code also take into account that when there is no third variable that only the first two need to be used, and when there is only a first variale that only one should be used? Example: mysite.com/product.php?Categorie=Hats&Subcategorie=Red-Hats would be rewritten in "mysite.com/Hats/Red-Hats/" and not "mysite.com/Hats/Red-Hats/ /", because if that is the case, should I also link to my category which are not dynamic pages like this to make sure everything is consistent?

3.c: shouldn't there be a http://mysitedotcom somewhere in the code (I once read that it was better to link with absolute links, cant remember why dough )


4. Could you explain what this line of code does exactly:

[PHPNET] while ($f = $res->FetchRow()) {
echo '<a href="' . writeUrl($f['slug'],$cat,$subCat) .'">' . $f['product_name'] . '</a>';
}[/PHPNET]

I think that it can be used to link to the product page with the product name, but what does "while ($f = $res->FetchRow()) " do and shouldn't the slug, cat and subcat be in a different order? I'm sure they dont, but im still a noob so im trying to understand what this line does...

301 redirect

5: Smart of ya to think ahead of old style URL's which might slip trough . However, "The easiest way is to check for the value of $_SERVER['REQUEST_URI']
If a '?' is present it's an old style one, and so retrieve the data, pass it through the writeUrl() function, and redirect."
is a bit to fast for me, how exactly would I do this?

6: The check for categories used to be a big problem for me as well. For instance: mysitedotcom/product?ID=1&Category=hat&name=super-hat would also be found when just using product.php?ID=1, because the GET only needed the ID variable. This ment that when a category changed Google wouldnt drop the old URL because the page could be found using the right ID and the old category names.

I never got a category check working, but if someone would link externally to mysitedotcom/hat/red-hats/super-hat/ and the category would change to green hat: mysitedotcom/hat/green-hats/super-hat/ , could the product then still be found because it automatically knows that the third "/" contains the slug variable?

7: I could indeed "hard code" the category and subcategorie from the category pages, e.g.: mysitedotcom/product.php?Category=Hat&Subcategory=Red-Hat&Name="variable URI"/. Is this what you meant?

Anyways, thanks a million for your clear explenation!

Nick


Quote:
Originally Posted by JagNet
Implementing mod_rewrite in the manner you've suggested is involved, but taken step by step it shouldn't be that daunting.

First thing is to take a look at the .htaccess rules, eg.
Code:
RewriteRule ^/(.*)/(.*)/(.*)\.html$ /product.php?Categorie=$1&Subcategorie=$2&Name=$3


Here you can see that we pass 3 variables, split by forward slashes, to the script: Categorie, Subcategorie, and Name. As you've already mentioned, the ID variable is no longer present, so that rules out the ability to fetch the required product from the database according to its ID number. Instead you need to look at what other variable you can use. In the case above that would be Name. It's still not ideal though, as in a larger shop there's plenty of opportunity to have more than one product with the same name. Secondly, you'd need to replace hyphens with spaces via php before calling the database, but what if the product name has hyphens in it? Too much possibility for error for my liking.

What to do then? My personal preference would be to introduce a new variable: Slug. This would be stored as a seperate, indexed column in the database, and would equate to the pseudo filename, avoiding any escaped characters. In your example URL ( /Hat/Red-Hat/Superflex-Red-Hat.html ), Slug would be "Superflex-Red-Hat".

So, instead of searching the database for $_GET['ID'], you'd be searching for $_GET['Slug'] (sanitizing the input of course).

The .htaccess code would then be something like:
Code:
RewriteRule ^/(.*)/(.*)/(.*)\.html$ /product.php?Categorie=$1&Subcategorie=$2&Slug=$3


Constructing the URL

The next step would be to create a function to construct the URL to maintain consistancy, eg

php Code:
Original - php Code
  1. function writeUrl($productSlug,$cat = false, $subCat = false) {
  2.   $url = '/';
  3.   if (!empty($cat)) {
  4.     $url .= $cat .'/';
  5.   }
  6.  
  7.   if (!empty($subCat)) {
  8.     $url .= $subCat .'/';
  9.   }
  10.   $url .= $productSlug . '.html';
  11.   return $url;
  12. }


So, in product category lists for example:
php Code:
Original - php Code
  1.  
  2.   while ($f = $res->FetchRow()) {
  3.     echo '<a href="' . writeUrl($f['slug'],$cat,$subCat) .'">' . $f['product_name'] . '</a>';
  4.   }


301 redirects

You also need to ensure that the old style URLs are no longer available. The easiest way is to check for the value of $_SERVER['REQUEST_URI']
If a '?' is present it's an old style one, and so retrieve the data, pass it through the writeUrl() function, and redirect.

By checking for old-style URLs it does at least mean that missing a hard-coded URL somewhere in your site isn't going to lead to duplicate pages.

I would also implement a check for the categories. If you happen to move the product to a different category, the URL would still work if you were just searching the database for $_GET['Slug'].

Perhaps even consider removing the categories from the URL altogether. That way it may be possible to remove some database requests for category data just to construct the URL (speeding up the site), and should you decide to change categories you don't have to change the URL as well (providing long term URL stability).



Without seeing the existing code for your site I can't really be any more precise, but it should at least give you some food for thought.

Reply With Quote
  #15  
Old September 10th, 2008, 06:32 AM
JagNet's Avatar
JagNet JagNet is offline
Smoke me a kipper...
SEO Chat Regular (2000 - 2499 posts)
 
Join Date: Aug 2007
Posts: 2,487 JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level)JagNet User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 3 h 37 m 22 sec
Reputation Power: 63
2) The "Slug" variable. Yes you can either manually add it to the database via phpMyAdmin, or create a new field in the admin form that adds products to the database, or have the script create it automatically from the product title. My preference would be the second option, as that would be the most convenient, and give me more control than the 3rd option.

3a) The function is simply a convenient way of constructing the URL. You could do without, but then it would result in more php code every time the script had to output a URL. Functions like these help reduce the number of lines of code, and help maintain consistency.

3b & c) You'd need to adjust the writeURL() function slightly, to account for the possibility of an empty slug variable. No reason why you couldn't add the full domain path into the function, or through a definition eg:
php Code:
Original - php Code
  1. #
  2. function writeUrl($productSlug = false,$cat = false, $subCat = false) {
  3.   $url = 'http://www.domain.com/';
  4.   if (!empty($cat)) {
  5.     $url .= $cat .'/';
  6.   }
  7.  
  8.   if (!empty($subCat)) {
  9.     $url .= $subCat .'/';
  10.   }
  11.  
  12.   if (!empty($productSlug)) {
  13.     $url .= $productSlug . '.html';
  14.   }
  15.  
  16.   return $url;
  17. }
  18.  
  19. /* example use for subcategory page */
  20. echo '<a href="'. writeUrl(false,$cat,$subCat) .'">';


4) This just serves as an example of looping through the products on a category page, outputting the link to individual products. I've used $f=$res->FetchRow() because I've been using database wrappers for too long and I can't for the life of me remember what the mysql php code is! As for the order of the three variables, you can put them in any order you like provided that they correspond to the order they appear in the function. If you changed it to cat,subcat,slug then you'd need to do the same for the function itself.

5) $_SERVER['REQUEST_URI'] is a global variable that returns the full path to the page minus the domain, eg:
www.domain.com/Hat/Red-Hat/Linux.html
$_SERVER['REQUEST-URI'] would be:
/Hat/Red-Hat/Linux.html

Thus, if you wanted to check for the presence of '?' in the URL:
php Code:
Original - php Code
  1.  
  2. if (strpos($_SERVER['REQUEST_URI'],'?') !== false) {
  3.   // do something here to pull the product slug and category information
  4.   // from the database based on $_GET['ID']
  5.   // (since it's an old URL, then ID should be present)
  6.  
  7.   header('HTTP/1.1 301 Moved Permanently');
  8.   header('Location: ' . writeURL($slug,$cat,$subCat));
  9. }


As always, there's various ways of achieving the same result using other $_SERVER variable, but that's my preferred.

6) Yes, if the database is queried only for the "Slug" variable, then it doesn't matter to the script what you put in the categories, hence my suggestion for checking that they are correct. Without the check someone could maliciously link to your site using the URL /teens/xxx/super-hat.html and it'd still work. Not what you'd want appearing in the search results!!

To perform the check you just need to pull the category information from the database for the product (don't know how the database tables are set up so can't really give any example code here), compile the URL as if you were creating a link, then check that against what is actually in the browser address bar. If they don't match, then again perform a 301 redirect.

7) My reference to "hard coding" simply means putting links in pages without constructing the URL dynamically, for example if you had a blog post and wanted to link to the product from there, you'd type in the URL just as you would if you were linking to an external site. You'd want to use the new style URLs though, rather than the old ones with a query string.

Reply With Quote
Reply

Viewing: SEO Chat ForumsGoogleGoogle Optimization > URL rewriting (?)


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT