Gossamer Forum
Home : Products : Gossamer Links : Discussions :

search engine friendly rewrite rules for '/'

(Page 1 of 2)
> >
Quote Reply
search engine friendly rewrite rules for '/'
I've been playing with this quite a bit, since I have my sites set up to use

http://domainname.com

as the entry point for links sql.

In the past, I used a rewrite rule:

RewriteRule ^/$ /path/to/page.cgi?d=1 [R,L,NC]

Or

DirectoryIndex index.html index.htm /path/to/page.cgi?d=1 [R,L,NC]

after reading about the rewrite rules, I kept trying, and came up with?

Code:

RewriteEngine On
RewriteRule ^/$ /resources/ [R,L,NC]
RewriteRule ^/resources/?$ /resources/

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



To use this, you must actually create the empty directory /resources off your server root.

Then, you must put the above into your virtual server's httpd.conf *OR* into the .htaccess in your ROOT WEB SPACE directory. (ie: where your index.html file for your domain would be).

Then, in your Links config, under Setup->paths you need to change the BuildURL and BuildPath to point to the above directory.

You must also check the "update others" box, then go back and edit the Image_URL to point back to your Images directory.

What this does, is rewrite the '/' call to the dummy directory, which rewrites to the g=/ call to page.cgi, which then triggers the build_root_url mechanism to rewrite any additional calls to the /resources/ directory.

Because of some quirks in how the html is written out, you need both lines above to catch the variations in how "root" URL's are written and rewritten.

I have this working on several sites, and have been testing them out for awhile, and it seems to work. I just set up two more sites today, using the above rules, and they worked right off. (Which is more than I can say for the last few <G>).

EDIT: I added [R,L,NC] after the first rewrite rule, after finding that googke [adsense] *much* prefers having a targeted URL. If you use 'sites' you will get served ads that are about domains, unless the targeting on your page is awesome. That's better than PSA's. Experiment with other rewrite directories to see which targets your site best (eg: /sites/, /resources/, /candies/, etc)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.

Last edited by:

pugdog: Mar 20, 2004, 7:13 AM
Quote Reply
Re: [pugdog] search engine friendly rewrite rules for '/' In reply to
Cool.

What url will actually show on the browser Url/Address bar?

Can a modification of this trick work with Gossamer Forum?
Quote Reply
Re: [webslicer] search engine friendly rewrite rules for '/' In reply to
An example is:

http://weddings101.com/...nd_Beauty/index.html

Your home URL will look like:

http://weddings101.com
http://weddings101.com/resources
http://weddings101.com/resources/

depending on where/how it's accessed.

Will it work for Gforum??? I don't know. GFORUM is *very* complex, and has it's own search engine friendly template set, and a means to make it work.

To see how that works, take a look at http://beadbanter.com which is running from the top URL using the search engine friendly templates.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] search engine friendly rewrite rules for '/' In reply to
Thanks!

The GForum SE friendly templates are great, and I do have them working
(Though it does take a lot of template editing, changing gforum.cgi to a full path)

... but I'd rather skip the "forum" subdirectory, and optionally the first Category Sub-directory(that's for sites using a single forum)

Why? Because of the search engines not liking multiple sub-sub firectories and the shift in indexing a post is given with sub-sub/sub directories.

Thus your url instead would look like:

http://beadbanter.com/...mstone_Pictures_F35/

with no "/forum

and
http://beadbanter.com/...mstone_Pictures_F35/

skipping the Category as well.

I'd also like to know how to show a single forum as the front page cleanly, as in: (for single forum sites)
http://beadbanter.com/

vs.

http://beadbanter.com/...mstone_Pictures_F35/

Is this possible?

Thanks for any help. I'm sure GForum owners would love to know how to do this.
Quote Reply
Re: [webslicer] search engine friendly rewrite rules for '/' In reply to
This will probably take a *lot* of rewrite rules. I'm not sure a complex regex would do it properly.

The reason is, they hinge on using the top-level directory /forum/ to pick off the urls to rewrite. Without it, the system falls apart.

For the other idea, you'd need to rewrite the various URL's to mimic the front page. This is where the many rewrite rules would possibly be needed, since the format of the incoming URL varies.

You might try to rewrite the URL starting with /forum/ to remove the /forum/ from the URL.

As for displaying the various forums as toplevel pages.... Have you thought about running inside a full-window frame?

It might defeat the search engines though.

I *think* there is a way to change the display URL, though, so every page would look like it's http://domain.com regardless of what the actual url was.

Not sure how exactly to implement that without affecting the rest of the site. I'm not a rewrite expert <G> Most of what I know is from brute force hacking on the system, not from some deep, elegant understanding of the mod_rewrite internals <G>


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] search engine friendly rewrite rules for '/' In reply to
Thanks very much, for the answer, Pudog. Was afraid the /forum directory was set up for that.

Frames, sorry, no, as they really are hated by the SE's, though they can make mask the cgi url very well.

Often I use SSI's to hide the cgi path. Maybe I can combine the SSI's with rewite rules.

I will continue exploring the possibilities.
Quote Reply
Re: [webslicer] search engine friendly rewrite rules for '/' In reply to
See the edit to the first message above. It *significantly* improves targeting on google's adwords, and changes how the site gets indexed.

It will return a 302 error, ie: Moved Temporarily, but usually those are completely ignored as still "good".


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] search engine friendly rewrite rules for '/' In reply to
If *anyone* is wondering if it's worth doing....

All I can say is *YES* <----

Unfortunately, I can't state more than that <G>

We'll post a new service on UltraNerds for changing your site around, if you are not able to do it yourself. You need to have mod_rewrite enabled, and allow overrides. Most shared and virtual hosting setups do.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] search engine friendly rewrite rules for '/' In reply to
This also seems to work quite well;

Code:
RewriteEngine On
RewriteRule (.*)\.css $1.css [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^(.*).html /cgi-bin/links/page.cgi?g=$1.html [L]
RewriteRule ^$ /cgi-bin/links/page.cgi [L]

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] search engine friendly rewrite rules for '/' In reply to
Thanks for the suggestions and comments.

Andy - cool, what exactly is that one doing? Can you please detail?

I'm still looking to eliminate the "forum" directory in the path of GForum....
Quote Reply
Re: [webslicer] search engine friendly rewrite rules for '/' In reply to
All my one will do, is stuff like;

Quote:
http://www.yoursite.com/folder ===> http://www.yoursite.com/cgi-bin/links/page.cgi
http://www.yoursite.com/folder/ ===> http://www.yoursite.com/cgi-bin/links/page.cgi
http://www.yoursite.com/folder/index.html ===> http://www.yoursite.com/cgi-bin/links/page.cgi?g=index.html
http://www.yoursite.com/folder/Test_Cat/index.html ===> http://www.yoursite.com/cgi-bin/links/page.cgi?g=Test_Cat/index.html

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
$100 Prize Offer In reply to
That's great, Andy, a lot of people need that. Rewrites are excellent.

Great explanation, by the way, thanks.

Now, If anyone comes up with a solution to the problem of getting rid of the /forum/ in GForum, let me know, I'm offering a $100 prize! Or code to build a static forum run on cron ....
Quote Reply
Re: [webslicer] $100 Prize Offer In reply to
I don't understand what the difficulty is getting rid of the forum/ with GForum. Can you explain exactly what it is that you want because I'm sure that it is possible.
Quote Reply
Re: [webslicer] $100 Prize Offer In reply to
No problem. What are you using for your GForum rewrite rules?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [afinlr] $100 Prize Offer In reply to
Sure;

The search engine frindly templates for GForum and the rewrite rules that go along with them make your forum appear as:

/forum/

What GForum webmasters has was:

http://www.GForumSite.com/...orum.cgi?post=131503

now we have (with the SE friendly templates and rewrite rules):

http://www.GforumSite.com/...ussion_Post_P104532/

I want to shorten this to:

http://www.GforumSite.com/...ussion_Post_P104532/

and on a site with only 1 category:

http://www.GforumSite.com/...ussion_Post_P104532/

but that part is pretty easy. Getting rid of the /forum directory is the hard part as the rewrite rules "seem" to need that.

Does that Help?
I can refer you also to the "Search Engine Friendly" Template posts on GForum is that helps.

http://www.gossamer-threads.com/...t_reply;so=ASC;mh=25;

My comments are on Page 3.

Thanks!
Quote Reply
Re: [Andy] $100 Prize Offer In reply to
Can get you the rewrite rules shortly, Andy - will take about an hour as they're on a different computer.
Quote Reply
Re: [webslicer] $100 Prize Offer In reply to
Ok, I may not be around then, but if noone else has checked by monday, I'll take a look for you.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [webslicer] $100 Prize Offer In reply to
So, having read that thread, what is wrong with these rules (need to go in your root directory rather than your forum directory) - I don't think I'm understanding what the problem is yet:

RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^\.htaccess$ - [F]

RewriteRule ^/.*P([0-9]+)/?$ /cgi-bin/forum/gforum.cgi?post=$1&t=search_engine [L]
RewriteRule ^/.*P([0-9]+)-([0-9]+)/?$ /cgi-bin/forum/gforum.cgi?post=$1&page=$2&t=search_engine [L]
RewriteRule ^/.*C([0-9]+)/?$ /cgi-bin/forum/gforum.cgi?category=$1&t=search_engine [L]
RewriteRule ^/.*F([0-9]+)/?$ /cgi-bin/forum/gforum.cgi?forum=$1&t=search_engine [L]
RewriteRule ^/.*F([0-9]+)-([0-9]+)/?$ /cgi-bin/forum/gforum.cgi?forum=$1&page=$2&t=search_engine [L]
RewriteRule ^/?$ /cgi-bin/forum/gforum.cgi?t=search_engine [L]
RewriteRule ^/.*gforum.cgi /cgi-bin/forum/gforum.cgi?%{QUERY_STRING} [R,NE,L]
Quote Reply
Re: [afinlr] $100 Prize Offer In reply to
Afinlr;

Cool. I will try that this afternoon.
If it works, fantastic, you made yourself $100!

Note that the rewrite rules work fine on my server, I'm just trying to get rid of one directory level.
Quote Reply
Re: [webslicer] $100 Prize Offer In reply to
I really don't think this is possible. the /forum/ is the flag used to trigger the system.

This might be possible using the Proxy/ProxyPass, to make it look like a different server/layout.

The problem is that with cgi, each request is a new one, and you have to give the server enough information to work with. If you strip out the /forum/ from the URL string, then any request that comes later, is not going to have the flag in it (the /forum/), and will fail.

The only way I can see around this is if your site was dedicated to the forum, you might be able to coax the rewrite rules to omit the /forum/, but then _every_ request to your server will be rewritten.

I kinda wish Alex would jump in here, as he's got a good grasp of what the rewrite rules can and can't do.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] $100 Prize Offer In reply to
I can see that there may be a problem if the templates have /forum hardcoded into their urls but I can't see what the problem is with these rewrite rules generally. I use lots of rewrite rules like this on my site and they all work fine.

In Reply To:

but then _every_ request to your server will be rewritten.[/quote]

Surely only the requests that fall into the rule set will be rewritten. You just need to make sure that your rules are specific enough to only pick up the requests that you want to be rewritten.

It may be that I'm not seeing the problem - all my rules are in a httpd.conf file and not in .htaccess - but I can't see why this would make a difference.
Quote Reply
Re: [afinlr] $100 Prize Offer In reply to
Hey, I hope you are right!
If you are... you will be RIGHT as well as $100 richer... :)

Sorry did not get to test it yet, looks like Monday. Cool?
Quote Reply
Re: [afinlr] $100 Prize Offer In reply to
The issue is getting rid of the flag directory /forum, /site, whatever.

If you are trying to use the '/' directory, then every url will get rewritten, that is the point.

By using a flag directory, you can specify the url set you want to rewrite.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [webslicer] $100 Prize Offer In reply to
Curious....

Did the rewrite rules work?

Did they work as written?

If not, what changes did you make?

This thread seems to be waiting for a final statement :)


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] $100 Prize Offer, now $250. In reply to
Hiya;

I am out of the country right now...

But no, so far I do not have a solution. It will take quite a bit of testing. It is still possible that I have been given the answer, though... but the testing is slow and i've covered only a few of the possibilities/variations.

Partially because it looks like the templates will have to edited to remove the /forum/ and on some places (header, footer, etc) the whole cgi path must be added, as /cgi-bin/forum/gforum.cgi also vs just gforum.cgi.

Of course, you casn try it yourself... search engine friendly at the root directory would perk everyone's ears up.

If you or someone else gets the whole solution working on a site I can look at and download the templates and .htaccess from (Forum 1.22 or latest) and I will up my offer to $250.


regards,

Mike
> >