Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Detailed pages and rewrite rules

(Page 3 of 5)
> > > >
Quote Reply
Re: [Andy] Detailed pages and rewrite rules In reply to
Thanks Andy! I'll give it a try and report back.
Quote Reply
Re: [ATKOgirl] Detailed pages and rewrite rules In reply to
Alex gave me this solution in a discussion awhile back:

Quote:


Links SQL can do search engine friendly URL's quite easily.
Simply create a directory in www called say 'portal', and then put an .htaccess there with:

RewriteEngine On
RewriteRule (.*) /cgi-bin/links/page.cgi?g=1 [L]

then in your admin area, set the url's to http://domain/portal.


I haven't tested this, but I know GT has given search engine friendliness a lot of thought over the years.

This is similar to andy's suggestion, just a different logic.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Detailed pages and rewrite rules In reply to
Thanks for your responses Andy and PugDog.

Unfortunately, I think I am doing something wrong, possibly the global entry - I tried to adapt the code that Ivan posted, but I don't think I got it right. Any assistance or insight anyone can offer is greatly appreciated.

ATKOgirl
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
This is a great addtion to Links SQL and it works fantastic but I have a question.

What do I need to do to change the way the url looks here

http://www.mysite.com/...n_Museum_Works_L606/

to just the url with the title?

http://www.mysite.com/...anklin_Museum_Works/

Thanks,

Craven
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Hi, I have been trying to figure out the rewrite rules. This seems to be where I am having problems. I have added the global "rewrite_url". This seems to work fine. I am forcing the link to be Detailed/title.shtml. This is how I would like the link to be if possible instead of Detailed/title_id.shtml. What I can't seem to do is get the detailed pages to actually build this way. They still build as Detailed/id.shtml.

I have tried adding this RewriteRule to my .htaccess in the admin folder of the linksql I have installed. The same one the points to the .htpasswd file.

RewriteEngine On
RewriteRule ^.*L([0-9]+).*\.shtml$ \/Movies/Detailed\/$1\.shtml [L]

I have tried various forms of this rule, but all I get are errors (internal server error & Forbidden)

The Global I am using is:

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

Help please. . .
Quote Reply
Re: [craven32] Detailed pages and rewrite rules In reply to


I don't think you can. The reason is that the title of the link, is not used as an index/key in the database. The rewrite rules work for categories, because the full-name of the category is what is passed to the g= parameter.

The same isn't true with a link. What is passed is the ID.

The original post used the _L flag to mark the beginning of the ID field. Any digits immediately following that flag were taken to be the ID (unique identifier of the link).

What's happening with the rewrite rules, is people see a small improvement, and they want everything ;) CGI is stateless, so you have to pass back EVERYTHING you want the server to do, inside the URL string, _or_ you have to use high-overhead session IDs, cookies, and other magic to record _probably_ where the is/was and wants to go.

To do what you want, you'd have to rewrite a few of the internal routines to recognize the passed in long string as a detailed name in lieu of an ID (not incredibly hard) and then you'd need to construct an index on the Title of the links, for performance, and debug a few things.

It's not trivial, but I'm not sure it can be done with rewrite rules. And, it might not work in every case, since most likely some rule sets would have to be created for deciding what is or is not a passed in "Title". You might have to use a rewrite rule to pick off .html page requests, and if they contain only a single '/' in the path, and end in .html assume that everything from the last / to the .html is the "Title" of the link, and search for it by passing it to a modified detail_page.cgi or jump.cgi

Not trivial, but potentially possible.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
Can you help - I'm trying to implement this for my detailed pages:

Have I made any obvious mistakes??

Read the thread & I tried to do this, using the info from the thread….:

I can see some of it working - BUT it doesn’t work completely…..

The links do not go to their detailed pages – they go to ErrorDocument 404

I can see the url appears to be formed for the link when I hover my “mouse” over the title of the link

I tried this on a "practice" site (this is where I “practice” – so that I don’t mess up my real site....)

Link.html:-- added: <a href="<%rewrite_url($ID,$Title)%>"><%Title%></a>

(first I forgot to remove this line…. so I had 2 title links for each vacancy!!!!)

<a class="link" href="<%detailed_url%>"><%Title%></a>

I removed <a class="link" href="<%detailed_url%>"><%Title%></a> from link.html

New Global: rewrite_url

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 . '/';
}

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

I had previously renamed the "Detailed" to read Some-thing (more appropriate for my site subject)


NOTE: I also have this: ErrorDocument 404 http://.......redirect.....url... in the htaccess file



Colin Thompson
Quote Reply
Re: [colintho] Detailed pages and rewrite rules In reply to
Thanks to Andy who kindly pointed me in the "right" direction

I managed to get this working

I edited the .htaccess......

RewriteEngine on

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

It now works

Thanks
Colin Thompson
Quote Reply
Re: [yogi] Detailed pages and rewrite rules In reply to
i'm having a few problems with this need help.

i set up the .htaccess file in my root dir

RewriteEngine On
RewriteRule ^.*L([0-9]+)/?$ \/sql212\/page.cgi?g=Detailed\/$1\.shtml [L]

I replaced the url in the links.html to
<a href="<%rewrite_url($ID,$Title)%>"><%Title%></a>

and i added the exact global

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 . '/'; }

when i have build detailed turned on i get normal detail links

when i have it turned off i get
http://mysite.com/...ag:%20'detailed_url'

I'm not sure where the problem is. I have tried different variations of the rewrite htaccess from this post without any luck. I have changed the original setup url extension to .shtml


htaccess is in my root file with the Detailed directory

Last edited by:

ken707: Apr 19, 2004, 10:10 AM
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
That rewrite rule won't work unless you have detail pages turned on. If you want to use dynamic detailed pages you need to use Pugdog's plugin. Then you can use this rule (assuming the cgi script is called detail_page.cgi):

RewriteRule ^.*L([0-9]+)/?$ /sql212/detail_page.cgi?ID=$1 [L]
Post deleted by ken707 In reply to
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
Hello,

I do have build detail turned on. I was only turning it on and off to locate the problem.

I changed the rewrite to
RewriteRule ^.*L([0-9]+)/?$ /sql212/page.cgi?ID=$1 [L]

and that did not work either it seems to keep going back to Detailed/9055.shtml or other link numbers

this is tuff Unsure
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
Hi,

Sorry, can you explain what the problem is again - I'm confused.

It sounds like everything works when you have build detail pages on and the rule in your first post? So what is it that you are trying to do?
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
When I have detailed build turned off it looks like the nice url is displayed on the links.html correctly except for the detail page id tag. http://mysite.com/...ag:%20'detailed_url'

When I turn build on, the link on the link.html looks like the normal detailed/1111.shtml

I'm not sure why the nice url does not display correctly and work when I turn build detailed on.



after each change i make i build all the database, not sure if this is necessary.
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
OK - I think I understand.

It sounds like you are still using <%detailed_url%> in the template rather than <%rewrite_url($ID,$Title)%>. This would lead to the exact problem you describe.

You shouldn't need to build to see what is going on - just view the site dynamically.
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
You were right. I guess it did not save when I uploaded the changed links.html I maded the change from the admin page.

Thanks, that part works but now i get a page error and the page does not appear.
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
Right. Try this rule:

RewriteRule ^.*L([0-9]+)/?$ /sql212/page.cgi?g=Detailed/$1.shtml [L]

If this gives you errors, can you have a look in your error log and paste what the error is.
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
I tried the new rule then checked it on a dynamic page and it did not work

i checked the error log and it says this a lot
File does not exist
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
it seems to be looking for the detailed page in the links files

public_html/Associations/Corrections/American_Correctional_Association_L8793.shtml

ithen it says file does not exist
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
When it says File does not exist - does it? I assume that you now have the correct url in the Links template and it is getting rewritten correctly. So the problem must be with the url that it is getting rewritten to?

If you type http://www.yoursite.com/...i?g=Detailed/1.shtml where 1 is the number of a link in your directory into your browser - does this work? Are you maybe missing cgi-bin from the path?
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
yes, that works

http://www.mysite.com/sql212/page.cgi?g=Detailed/9549.shtml
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
In Reply To:
public_html/Associations/Corrections/American_Correctional_Association_L8793.shtml[/quote]
Is the .shtml really there? It shouldn't be.
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
yes it was.

i put .shtml in the global were the / was at the end
i changed it back $ID . '/'; }

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 . '/'; }


it still does the same thing. it does not seem to find the detailed page
Quote Reply
Re: [ken707] Detailed pages and rewrite rules In reply to
This would be so much easier if I had access to your site Wink.

Can you try typing this into your browser to test your rewrite rule:

http://www.yoursite.com/_L8793
Quote Reply
Re: [afinlr] Detailed pages and rewrite rules In reply to
I sen tyou a private mesage with my url

it does seem to be working. i guess it may be the rewrite rule
> > > >