Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Detailed pages and rewrite rules

(Page 1 of 5)
> >
Quote Reply
Detailed pages and rewrite rules
I have just added a nice rewrite rule that allows my to detailed pages with the following url

http://www.domain.com/dir1/dir2/dir3/Title_of_the_Link_L123/

instead of

http://www.domain.com/Detailed/123.html

which is (I think) better for google and the like. This only works in static mode, btw.

In order to do this, you need a global, called rewrite_url, which is
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 '/' . $cat_url . '/' . $Title . '_L' . $ID . '/';
}
which you can use in your link.html template as
<a href="<%rewrite_url($ID,$Title)%>"><%Title%></a>

The rewrite rule you need to add is something like

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

Ivan
-----
Iyengar Yoga Resources / GT Plugins

Last edited by:

yogi: Sep 11, 2002, 6:33 AM
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
What a great idea Ivan!

I want to tell my prospective clients that they can use the detailes page as their web page. Your version of the URL looks so much more attractive!

Thanks! You're the best!!! Cool

If you love cats - visit www.TheCatSite.com

Visit my LinkSQL based Cat Site - www.Meowhoo.com
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Why would you have tabs, carriage returns and newlines in your title? Wink
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
I'd just like to bring this up again, because my detailed pages have been spidered by google a while back. Because of these rewrite rules (and because of the good content, of course), many of the detailed pages appear first (or very high) in search results when somebody is searching for words that are in the title of the link.

So, I can only recommend these rewrite rules once more.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Where do you add the rewrite rule and does it work in both static and dynamic mode?

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Detailed pages and rewrite rules In reply to
You add the rewrite rule either in httpd.conf, or in a .htaccess file in your root directory. The rewrite rules I gave are for static mode, but they could easily be changed for dynamic mode.

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Ok so if I make a .htaccess file in the root directory of links (where pages are built) - it should work?

And how about Dynamic mode - would the page be generated using the link to the page or does it need some modification?

I am keen to do this as I don't feel comfortable having thousands of detailed pages in one directory - so even if I could get /dir1/dir2/dir3/123.html I would be quite happy - but I need it to work both in static and Dynamic mode...

Klaus

http://www.ameinfo.com
Quote Reply
Re: [klauslovgreen] Detailed pages and rewrite rules In reply to
If you do what I posted above, you will still generate all your detailed pages in one directory, only the URL to them will be very nice-looking.

If you need to have both dynamic and static mode, then you would need to add some more rules (one rule for dynamic pages, one rule for static pages).

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Hi yogi, nice feature ...

I have one small problem.

When the link is placed in more than one category, nice_looking_URL will change to URL with category which has the highest Category ID Unsure

Is there a way to improve this fix so that nice_looking_URL is built with desired Category ID?

Thanks!

Last edited by:

Payooo: Feb 8, 2003, 9:51 AM
Quote Reply
Re: [Payooo] Detailed pages and rewrite rules In reply to
It's not possible to select the category that is displayed for links which are in several categories. The way it's coded is similar to (and consistent with) the 'title_linked' tag.

What you want could of course be done, but I don't have the time for this right now. Feel free to try yourself.Smile

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Does rewrite effect server load? Are there any drwabacks to using this method? All of the sites are on a shared server environment and must play well with others in terms of server resources. But this looks like a good idea.

Can the detailed pages still be accessed from their detailed directory if you were to type it in directly?

Thanks Yogi!
Quote Reply
Re: [Evoir] Detailed pages and rewrite rules In reply to
Does rewrite effect server load? Are there any drwabacks to using this method? All of the sites are on a shared server environment and must play well with others in terms of server resources. But this looks like a good idea.


- I don't know. (I don't think so)




Can the detailed pages still be accessed from their detailed directory if you were to type it in directly?


- Yes
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
 
Ok - I'm convinced :)

Is there a way to create the url with the .html extension instead of an end /

I suspect this can be changed via the rewrite rule global?

--------------------------------
Privacy Software
Quote Reply
Re: [Payooo] Detailed pages and rewrite rules In reply to
What if you wanted to keep the original directory url for detailed pages instead of using the category. I can see a legitimate use for it this way too.

--------------------------------
Privacy Software

Last edited by:

BLOOD: Feb 13, 2003, 2:01 PM
Quote Reply
Re: [BLOOD] Detailed pages and rewrite rules In reply to
I don't quite understand what you are trying to do... could you maybe give an example?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Hi,

Yes - instead of the global producing the url as :

http://www.domain.com/dir1/dir2/dir3/Title_of_the_Link_L123/

I think it would also be great to produce the link using the detailed directory as defined in the admin thus:

http://www.domain.com/Detailed/Title_of_the_Link_L123.html

I assume this is not to hard to do with your code?

--------------------------------
Privacy Software

Last edited by:

BLOOD: Feb 13, 2003, 2:12 PM
Quote Reply
Re: [BLOOD] Detailed pages and rewrite rules In reply to
Code:
sub {
my $ID = shift;
my $Title = shift;
$Title =~ y/ \t\r\n?"'#/__/d;
return $CFG->{build_detail_url} . '/' . $Title . '_L' . $ID . '/';
}

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Works perfectly!

Now I feel very cheeky asking this as you have given so much. Would it be possible to have the url end in .html instead of / so we have this:

Title_of_the_Link_L123.html

I assume using rewrite rules this would be legitimate?

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Detailed pages and rewrite rules In reply to
I guess the rewrite rule needs to be:

RewriteRule ^.*L([0-9]+)\.html$ /Detailed/$1.html [L]

and the change in the global is left as an exercise for the reader Wink

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
I have actually been trying to change this all week! But im sure I can work with the new code.

Cheers!

--------------------------------
Privacy Software
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Rewrite rules are so complex!


RewriteRule ^.*L([0-9]+)\.html$ /Detailed/$1.html [L]

Now im trying to swap over the position of the link id to this:

11_anything.html

I have the global changed OK, its just the rewrite.

But so far its not working Mad

--------------------------------
Privacy Software

Last edited by:

BLOOD: Feb 14, 2003, 3:16 PM
Quote Reply
Re: [BLOOD] Detailed pages and rewrite rules In reply to
What code have you tried?
Quote Reply
Re: [Paul] Detailed pages and rewrite rules In reply to
Not understanding rewrite rules fully is confounded by lack of tutorials on the net. Anyhow I have this

RewriteRule ^([0-9]+).*\.html$ /Detailed/$1.html [L]

--------------------------------
Privacy Software

Last edited by:

BLOOD: Feb 15, 2003, 2:27 AM
Quote Reply
Re: [BLOOD] Detailed pages and rewrite rules In reply to
Ok I got it. I just hope it's efficient!

RewriteRule ^.*L([0-9]+).*\.html$ /Detailed/$1.html [L]

--------------------------------
Privacy Software
Quote Reply
Re: [BLOOD] Detailed pages and rewrite rules In reply to
Hi,

this issue sounds very interesting!




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




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



RewriteRule ^.*L([0-9]+).*\.html$ /Detailed/$1.html [L]






How should this all look that it works in both static and dynamic mode???

Regards,
Manu

Shopping Portal Shop-Netz.de® | Partnerprogramme | Flugreisen & Billigflüge | KESTERMEDIA e.K. | European Affiliate Marketing Forum.
> >