Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Dynamic to Static-look URLs -- hints

Quote Reply
Dynamic to Static-look URLs -- hints
Over the years, since the version 1.x betas, i've played with rewriting the http://domain.com format, into the home.html template of Links SQL.

I've learned a few things ,and in light of recent discussions I'll pass a few on.

The format I use is:

Code:

RewriteRule ^/$ /empty_dir/ [R,L,NC]
RewriteRule ^/empty_dir/?$ /empty_dir/ [L,NC]

<Directory /var/home/path/to/empty/empty_dir/>
Options All -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule (.*) /cgi-bin/LinkSQL/page.cgi?g=$1 [L]
AllowOverride All
Allow From All
</Directory>


First, you need to set up the first two rewrite rules, then create an EMPTY directory, in the public tree, that is used to force the rewrite. The above <directory> directives are in my httpd.conf file, but can be used in an .htaccess file.

The red R is optional, and I'll explain it later. The blue "/" is _MANDATORY_ and this line prevents Links from generating "We do not have a category..." and printing out your path name as an error.

The green [L,NC] _seems_ to be a good idea, but it doesn't always work, and I'm not sure why.

Back to the first rewrite rules.

The first rule rewrites your domain name to the empty directory, which forces _everything_ to pass through the page.cgi file.

When you add an R to the flags, you will get a visible URL :

http://domain.com/empty_dir/

This often shows _NO_ page rank, and gives people ulcers. If you add the R, you'll see:

http://domain.com/

That "appears" better to most people, but I did some checking on sites I had running for at least 6 months to a year, or more, and when I changed the [R,L,NC] that was showing /empty_dir or /empty_dir in the URL -- with a PR of 0, to [L,NC], when I looked at the http://domain.com/ resulting url, some pages were as high as a 6. *SO* google ignored the rewrite completely, and ranked the incoming URL, anyway.

How this translates into search engine listing, I don't know, but I'd take a PR of 6 any day <G>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Dynamic to Static-look URLs -- hints In reply to
In Reply To:

The format I use is:

Code:

RewriteRule ^/$ /empty_dir/ [R,L,NC]
RewriteRule ^/empty_dir/?$ /empty_dir/ [L,NC]

<Directory /var/home/path/to/empty/empty_dir/>
Options All -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule (.*) /cgi-bin/LinkSQL/page.cgi?g=$1 [L]
AllowOverride All
Allow From All
</Directory>



First, you need to set up the first two rewrite rules, then create an EMPTY directory, in the public tree, that is used to force the rewrite. The above <directory> directives are in my httpd.conf file, but can be used in an .htaccess file.

The red R is optional, and I'll explain it later. The blue "/" is _MANDATORY_ and this line prevents Links from generating "We do not have a category..." and printing out your path name as an error.

The green [L,NC] _seems_ to be a good idea, but it doesn't always work, and I'm not sure why.

Back to the first rewrite rules.

The first rule rewrites your domain name to the empty directory, which forces _everything_ to pass through the page.cgi file.

When you add an R to the flags, you will get a visible URL :

http://domain.com/empty_dir/

This often shows _NO_ page rank, and gives people ulcers. If you add the R, you'll see:

http://domain.com/

That "appears" better to most people, but I did some checking on sites I had running for at least 6 months to a year, or more, and when I changed the [R,L,NC] that was showing /empty_dir or /empty_dir in the URL -- with a PR of 0, to [L,NC], when I looked at the http://domain.com/ resulting url, some pages were as high as a 6. *SO* google ignored the rewrite completely, and ranked the incoming URL, anyway.

How this translates into search engine listing, I don't know, but I'd take a PR of 6 any day <G>
I tried your code in an .htaccess file in a subdomain. Of course it failed, or I wouldn't be writing.

I got a 500 error from the start. I created an empty directory in the public area called /news, replaced /empty_dir/ with /news/ in the script, and tried every variation I could think of for <Directory /var/home/path/to/empty/empty_dir?> without any success. Of course, since in my install the page.cgi is in /cgi-bin/, I modified that path in the RewriteRule as well.

Perhaps, as a 'gotcha', it might help to know I have standard HTML pages in the same subdomain, with those pages linking off to the dynamic GL install, yet simply trying to reach the site's index.html page causes the 500 error.

I'm thinking I'm missing something basic, but I don't know much about mod_rewrite (and not much more about .htaccess itself), so can you give me the dummy version of your code?

Alan Frayer
Don't just read the news - make the news!
Your World News - http://yourworldnews.frayernet.com
Quote Reply
Re: [afrayer] Dynamic to Static-look URLs -- hints In reply to
Apparently the <Directory> directive is one of those directives that cannot be used in .htaccess, hence my error and questions.

What I need is to use mod_Rewrite to redirect/rewrite just the GL3 pages, as they are the only dynamic pages of my site. How do I write the .htaccess file to redirect/rewrite only the dynamic pages, ignoring the static pages?

Alan Frayer
Don't just read the news - make the news!
Your World News - http://yourworldnews.frayernet.com

Last edited by:

afrayer: Aug 8, 2006, 8:57 AM
Quote Reply
Re: [afrayer] Dynamic to Static-look URLs -- hints In reply to
I played with Pugdog's mod_rewrite script (with the help of a basic tutorial on mod_rewrite), and when I was able to get a response, all it would do is drop me into static pages. Clearly, that is not what I want, or I'd simply switch from dynamic to static pages.

I probably did it wrong, but I don't see how to do it right; if I can't pass the d=1 to each page, the system tries to use static pages, instead. So much for mod_rewrite.

Alan Frayer
Don't just read the news - make the news!
Your World News - http://yourworldnews.frayernet.com
Quote Reply
Re: [afrayer] Dynamic to Static-look URLs -- hints In reply to
I'm not sure what you mean. This has been working for years.

The pages generate look static, and the links in them look static, but they actually are rewritten to the dynamic url.

You don't have to generate any pages, "rebuild" your site, or do anything. Any time a page is displayed, it is *really* dynamically generated, but the output looks like it was a standard static webpage.

d=1 doesn't have to be passed through for this to work properly. Because each and every page is *actually* dynamic, the d=1 parameter doesn't matter. *every* page click goes through the page.cgi system.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Dynamic to Static-look URLs -- hints In reply to
In Reply To:
I'm not sure what you mean. This has been working for years.

The pages generate look static, and the links in them look static, but they actually are rewritten to the dynamic url.

You don't have to generate any pages, "rebuild" your site, or do anything. Any time a page is displayed, it is *really* dynamically generated, but the output looks like it was a standard static webpage.

d=1 doesn't have to be passed through for this to work properly. Because each and every page is *actually* dynamic, the d=1 parameter doesn't matter. *every* page click goes through the page.cgi system.
I have some old, static pages sitting on the site. Nothing points to them, and the mod_rewrite instructions went to an empty directory, as you indicated. When I reworked your code to remove the <Directory> directive, the site started serving me the old static pages (outdated content was the clue, along with menu URLs that pointed to the /cgi-bin/pages/ directory).

I think I need far more than simple fine-tuning to make the site behave right. I simply ran out of time to figure it out.

Alan Frayer
Don't just read the news - make the news!
Your World News - http://yourworldnews.frayernet.com