Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Detailed pages and rewrite rules

(Page 5 of 5)
> >
Quote Reply
Re: [hmc] Detailed pages and rewrite rules In reply to
In Reply To:
how its possible to use "-" not a "_" in for the the title?

Modify the rewrite_url global given by yogi on page 1 of this thread to this:

Code:
sub {
my $ID = shift;
my $Title = shift;
my $cats = $DB->table('Links')->get_categories($ID);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/-/d;
return '/detail/' . $Title . '-L' . $ID . '.html';
}

That should do it (everything else remains the same I think). Note that I have modified the last line so that detailed links on my site are all in a directory called 'detail' - if they are in cat1/cat2/cat3 for example there is a danger of them getting 'buried' too deep in the site.
Quote Reply
Re: [aus_dave] Detailed pages and rewrite rules In reply to
I need help with this mod.

Iīve added
sub {
my $ID = shift;
my $Title = shift;

my $cats = $DB->table('Links')->get_categories($ID);
my ($cat_id,$cat_full_name) = each %$cats;
my $cat_url = $DB->table('Category')->as_url($cat_full_name);
$Title =~ y/ \t\r\n?"'#/__/d;
return '/' . $cat_url . '/' . $Title . '_L' . $ID . '/';
}and <a href="<%rewrite_url($ID,$Title)%>"><%Title%></a> in link.htmland RewriteRule ^.*L([0-9]+)/?$ /Detailed/$1.html [L] in my .htaccessbut links wonīt build the pages at all. links just builds 1.html etc..Whem i hover my mouse over my detailed links i can see the Link_L1 but when i click on the link its 404 of cource. So why isnīt links building those pages?
Quote Reply
Re: [drumstick] Detailed pages and rewrite rules In reply to
The point of using rewrite rules is generally to make the site appear static when it is actually dynamic.
This rule:
RewriteRule ^.*L([0-9]+)/?$ /Detailed/$1.html [L]
means that when you click on a link blabla_L1 it is actually looking for /Detailed/1.html
Therefore, the _L1 url does not exist on your server - Links wont build these pages. However, if you are getting a 404 error and /Detailed/1.html does exist - the rewrite rule is not working. My guess is that you need
RewriteRule ^/.*L([0-9]+)/?$ /Detailed/$1.html [L]
but you can check what it is doing by changing [L] to [R].
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
More trouble with ReWrite module..

These are my settings

rewrite_url
sub {
my $ID = shift;
my $Title = shift;
$Title =~ y/ \t\r\n?"'#/__/d;
return $CFG->{build_detail_url} . $Title . '.html';
}

link.html
<a href="<%rewrite_url($ID,$Title)%>"><%Title%></a>

.htaccess
RewriteEngine On
RewriteRule ^.*L([0-9]+)/*/?$ /$1.html [L]

My detailed pages are built in my root directory. (http://www.domain.com/1.html)
But I want to have my detailed link to http://www.domain.com/test.htm

Any ideas howto solve this?
Thanks!
Quote Reply
Re: [rob99] Detailed pages and rewrite rules In reply to
Hi,

Unfortunately it isn't that simple.
When you click on the link .../title.html - how will it know which link to pick out of the database? You need the id in there somewhere.
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
OK, i can live with that. however still getting errors :(

rewrite_url
sub {
my $ID = shift;
my $Title = shift;
$Title =~ y/ \t\r\n?"'#/__/d;
return $CFG->{build_detail_url} . $Title . '_L' . $ID . '.html';
}

htaccess
RewriteEngine On
RewriteRule ^/.*L([0-9]+)/?$ /$1.html [L]

pages built as www.domain.com/1.html
they link as www.domain.com/title_1.html

But im getting 404's :(

Any thoughts?

Last edited by:

rob99: Oct 10, 2005, 10:56 AM
Quote Reply
Re: [rob99] Detailed pages and rewrite rules In reply to
From a quick look - I think it might be this:

RewriteRule ^/.*L([0-9]+).html$ /$1.html [L]
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
no luck with that :(
Quote Reply
Re: [rob99] Detailed pages and rewrite rules In reply to
Try changing the [L] to an [R] to see what is going on.
Also try removing the first /
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
It worked with removing the first /
Thanks for your help, much appreciated :)

Cheers!
Quote Reply
Re: [rob99] Detailed pages and rewrite rules In reply to
Great. I know how frustrating it can be getting these rules to work! But once they do ... I now have hundreds of them.
> >