Gossamer Forum
Home : Products : Links 2.0 : Customization :

SEF Module

Quote Reply
SEF Module
I've make a small sef module to make links 2.0 more Search Engine Firiendly, the module user Mod_Rewrite do modify the url from:

http://www.sitename.com/...ory/subcat2/subcat3/

to

http://www.sitename.com/...ategory-category.htm

You can see the mod morking here: www.travelstarthere.com

Here how to implement this mod:

Edit links.cfg

find: # URL of User CGI directory. No Trailing Slash.

up of this write:

Code:

###### Mod_Rewrite Option
###### Set to 1 enable the Mod_Rewrite
$mod_rewrite = 1;



now save this file and open site_html_template.pl

find and delete this line:

Code:
$url = "$build_root_url/" . &urlencode($subcat) . "/";




now write as follow:

if ($mod_rewrite eq 1) {
## Modifica l'url per il rewriteRule
@cats = split(/\//,$subcat);
my $newurl = "";
for ($count = $#cats; $count >= 0; $count--) {
if ($count ne 0) {
$newurl .= $cats[$count] . "-";
} else {
$newurl .= $cats[$count]; }
}
$url = &urlencode($newurl) . ".htm";
} else {
# First let's get the name, number of links, and last modified date...
$url = "$build_root_url/" . &urlencode($subcat) . "/";
}


Now you have to modify your .htaccess file adding:

RewriteEngine on
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$1/$2/$3/$4/$5/$6/$7/$8/$9/$10/
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$1/$2/$3/$4/$5/$6/$7/$8/$9/
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$1/$2/$3/$4/$5/$6/$7/$8/
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$1/$2/$3/$4/$5/$6/$7/
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$1/$2/$3/$4/$5/$6/
RewriteRule ^(.*)-(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$5/$4/$3/$2/$1/
RewriteRule ^(.*)-(.*)-(.*)-(.*)\.htm$ catalog/$4/$3/$2/$1/
RewriteRule ^(.*)-(.*)-(.*)\.htm$ catalog/$3/$2/$1/
RewriteRule ^(.*)-(.*)\.htm$ catalog/$2/$1/
RewriteRule ^(.*)\.htm$ catalog/$1/

The rewrite rule work only up to 10 subcats, i didn't find any other way to write this rule, maybe someone can help.
I hope this help.
Bye
Quote Reply
Re: [gamluca] SEF Module In reply to
Just now i realyze the Links need some other modification, for the New Page and the Cool page, here the modification for the New page:

open nph-build.cgi, find and delete this line (inside the sub build_new_page):

$link_results .= qq|<A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;

now write:

if ($mod_rewrite eq 1) {
## RewriteMod Modification
@cats = split(/\//,$category);
my $newurl = "";
for ($count = $#cats; $count >= 0; $count--) {
if ($count ne 0) {
$newurl .= $cats[$count] . "-";
} else {
$newurl .= $cats[$count]; }
}
$url = &urlencode($newurl) . ".htm";
$link_results .= qq|<A HREF="/$url">$category_clean</A>\n|;
} else {
$link_results .= qq|<A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
}

here the modification for the cool page:

open nph-build.cgi
find and delete (inside the sub build_cool_page):
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;

now write:

if ($mod_rewrite eq 1) {
## RewriteMod Modification
@cats = split(/\//,$category);
my $newurl = "";
for ($count = $#cats; $count >= 0; $count--) {
if ($count ne 0) {
$newurl .= $cats[$count] . "-";
} else {
$newurl .= $cats[$count]; }
}
$url = &urlencode($newurl) . ".htm";
$link_results .= qq|<P><A HREF="/$url">$category_clean</A>\n|;
} else {
$link_results .= qq|<P><A HREF="$build_root_url/$category/$build_index">$category_clean</A>\n|;
}

Last edited by:

gamluca: Sep 15, 2006, 10:36 AM
Quote Reply
Re: [gamluca] SEF Module In reply to
maybe this will be of help:

http://rewrite.drbacchus.com/rewritewiki/RewriteMap


RewriteMap lets you use a script to handle the rewrites.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] SEF Module In reply to
Thanks, is very interesting, but i still finish and is working very good.Angelic
I'm not expert at all with rewrite rule i i try to find a workaround !!!
Quote Reply
Re: [gamluca] SEF Module In reply to
Hello, how must i change the code when i have no special directory for Links 2.0 pages?

Example: When i use your modification perhaps for

http://www.domainexample.com/links/houses

your code is nice!

But when I will use it for

http://www.domainexample.com/houses

nothing will happen.

I will be very happe for any answers Smile
Quote Reply
Re: [teratec] SEF Module In reply to
Did you put the modified .htaccess file in the same (root) directory?


Leonard
aka PerlFlunkie
Quote Reply
Re: [PerlFlunkie] SEF Module In reply to
Hello, the Problem is not the .htaccess-File, the problem is, that links 2.0 does not generate pages for search engines like http://www.domainexample.com/category.html . The mod rewrite produces only search engine friendly pages, when i have a special directory for links 2.0 pages. But when i generate the pages in root-directory the mod rewrite above doesn´t create pages like

http://www.domainexample.com/category1.html
http://www.domainexample.com/...category1-black.html , etc.
Quote Reply
Re: [teratec] SEF Module In reply to
Hi,

a very intersting mod.

Is there a way to use something like this to change

http://www.example.com/...nks/jump.cgi?ID=6128

to http://www.target-site.com

So that google can index the target site, but hits are still counted?

Best,
Karl