Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Category names and htaccess

Quote Reply
Category names and htaccess
I am having problems with Category Names containing dashes and spaces...

The error:
Quote:
A fatal error has occured:

Invalid SiteHTML method: 'site_html_index.html'. at /home/virtual/site129/fst/var/www/cgi-bin/links/admin/Links/SiteHTML.pm line 280.

Please enable debugging in setup for more details.


My error can be seen here by clicking on "Rap - Hip Hop":
http://www.supportmusicians.com/Band_Websites/index.html


The problem is weird because Some categories can have dashes and others cant.
I think it is a rewrite rule problem.

These (brand new) category names initially work...
Word Space - Dash
Word - Dash Space
Rap - Hip Hop2

I want a category Named "Rap - Hip Hop"

So I rename "Rap - Hip Hop2" to "Rap - Hip Hop", and it breaks.
Deleting my htaccess fixed the problem, so Here's my rewite rules is somone can help.



Why can I have a category named "Word Space - Dash", or "Word - Dash Space", or even "Rap - Hip Hop2", but I can't use "Rap - Hip Hop" ?
Code:
RewriteEngine On
RewriteRule (.*).css $1.css [L]
RewriteRule (.*)\.js $1.js [L]
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.gif $1.gif [L]
RewriteRule (.*)\.jpg $1.jpg [L]
RewriteRule (.*)\.png $1.png [L]
RewriteRule (.*)\.mp3 $1.mp3 [L]
RewriteRule (.*)\.swf $1.swf [L]
RewriteRule (.*)\.xml $1.xml [L]
RewriteRule p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]
RewriteRule search/(.*) /cgi-bin/links/search.cgi?query=$1 [L]
RewriteRule jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]
RewriteRule images/(.*) images/$1 [L]
RewriteRule .*L([0-9]+)/?$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule .*L([0-9]+)\.html$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule Detailed/(.*)\.html /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule (.*) /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule /?$ /cgi-bin/links/page.cgi [L]

Something else seems to be going on, but using the real url below seems to work, so it must be the .htaccess file correct?

This works, with "Rap - Hip_Hop" or "Rap - Hip_Hop2" using correct version of course
http://www.supportmusicians.com/cgi-bin/links/page.cgi?g=Band_Websites%2FRap_-_Hip_Hop%2Findex.html;d=1

I have just started using subcategories. Before yesterday I had no subcategories, and d this issue didn't exist.

Thanks
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Category names and htaccess In reply to
Hi,

Try changing;

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

to;

RewriteRule ^(.*)/index\.html$ /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule ^(.*)/?$ /cgi-bin/links/page.cgi?g=$1/index.html [L]

Also, I think your main problem is this line;

RewriteRule p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]

..try changing to;

RewriteRule ^p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]

By the looks of it, the URL;

http://www.supportmusicians.com/Band_Websites/Rap_-_Hip_Hop/index.html

Its grabbing this part;

p/index.html ... and thus not passing the right value in.

Hope that helps Smile

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] Category names and htaccess In reply to
That helps a LOT :-)

Thank you Andy.

I knew something was wierd. It was categories that ended in p.
Too funny.

No wonder I wasn't able to use:
- New Wave and Synthpop
- Rap and Hip-Hop
- Rock and Pop

"Your" rewrite rule is turning out to be a masterpiece.

Thanks again,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Category names and htaccess In reply to
Oh, little bummer...

http://www.supportmusicians.com/index.html

Produces...
Quote:
Oops, we had the following problem:
Category 'index.html' does not exist.

The "Home" link in Navigation bar links to:
http://www.supportmusicians.com/
This works fine.

Crumb links to:
http://www.supportmusicians.com/index.html
and this gives the error above.


htaccess...
Code:
RewriteEngine On
RewriteRule (.*).css $1.css [L]
RewriteRule (.*)\.js $1.js [L]
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.gif $1.gif [L]
RewriteRule (.*)\.jpg $1.jpg [L]
RewriteRule (.*)\.png $1.png [L]
RewriteRule (.*)\.mp3 $1.mp3 [L]
RewriteRule (.*)\.swf $1.swf [L]
RewriteRule (.*)\.xml $1.xml [L]
RewriteRule ^p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]
RewriteRule search/(.*) /cgi-bin/links/search.cgi?query=$1 [L]
RewriteRule jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]
RewriteRule images/(.*) images/$1 [L]
RewriteRule .*L([0-9]+)/?$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule .*L([0-9]+)\.html$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule Detailed/(.*)\.html /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule ^(.*)/index\.html$ /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule ^(.*)/?$ /cgi-bin/links/page.cgi?g=$1/index.html [L]
RewriteRule /?$ /cgi-bin/links/page.cgi [L]
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Category names and htaccess In reply to
Hi,

No worries Smile

You could try adding this;

Code:
RewriteRule ^/index.html$ /cgi-bin/links/page.cgi [L]

..just before;

Code:
RewriteRule /?$ /cgi-bin/links/page.cgi [L]

Hope that helps.

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: [rgbworld] Category names and htaccess In reply to
Code:
RewriteRule ^(.*)/index\.html$ /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule ^(.*)/?$ /cgi-bin/links/page.cgi?g=$1/index.html [L]

The first rule, translates

http://domain.com/index.html

into

..../page.cgi?g=/index.html

The home page is a special case.

Add

RewriteRule ^/index\.html$ /cgi-bin/links/page.cgi [L]


This is really messy.

Can I ask why you are doing it this way? part of the problem, I would also imagine, is you are serving up the site with page.cgi, and not using the d=1 parameter.

Also, you have
RewriteRule (.*).css $1.css [L]
as your first rewrite rule. Do you need that? It might bite you one day.

Code:

RewriteEngine On
RewriteRule (.*).css $1.css [L]
RewriteRule (.*)\.js $1.js [L]
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.gif $1.gif [L]
RewriteRule (.*)\.jpg $1.jpg [L]
RewriteRule (.*)\.png $1.png [L]
RewriteRule (.*)\.mp3 $1.mp3 [L]
RewriteRule (.*)\.swf $1.swf [L]
RewriteRule (.*)\.xml $1.xml [L]
RewriteRule p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]
RewriteRule search/(.*) /cgi-bin/links/search.cgi?query=$1 [L]
RewriteRule jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]
RewriteRule images/(.*) images/$1 [L]

The code in blue is not anchored, it could cause problems later on.

Also, you are trying to get "clever" with your rewrite rules, and it's going to really limit you in the future, and some of this is going to come back and really bite you as your site grows, if you don't enforce strict rules on where you data is placed.

you are using /images/ (or should be) and all your image types should be in that directory tree. Period. You don't need to rewrite all the image types at the top of the file. Same for the various media types. put them in /directory/ and rewrite that directory, not files.

If you are using http://domainname.com/jump/99999 anchor it, so the rule kicks in only where you expect.

RewriteRule ^/jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]

Although ^/jump/(\d+)$ would be better -- match only if the user entered /jump/[digits]

Are you doing this to get rid of the extra directory in the standard 'static' rewrites? FWIW, there is a *really* good set of reasons *NOT* to, and very, very few even half-good ones to do that.

You are locking your site down to a very specific format, and if you have to (or want to) change it around later, you will pretty much lose all your search engine rankings, since you have no way to rewrite the old url's to the new ones without creating a host of really bad problems.

if you used /resources/ as your directory, if you had to make a change, you could 301 *everything* that came in as /resources/ to an entirely new domain with a single rule.

The way you have it now, will give you ulcers if you have to modify your site.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Category names and htaccess In reply to
Too all the above. I give.

Thank you both for all your help. I thought it was all working fine, then I added a subcategory and a few items broke, so on one hand, I am so close, and "we" all have soooo much time invested in this, it would be nice to get-er-done. On the other hand, if it's "messy" and there is a better way of setting this up for search engine friendly urls, then let's do that.

On the 3rd hand :-)
I am at the point of forgetting rewrite altogether and just hope for the best with search engines.

I am already paying websitepros to do search engine submissions, etc...
I have had this set of rewrite rules in place before that happened (2 weeks ago)

Pugdog...
Andy helped me write these rules and I thank him verrry much for doing so.
I duplicated a couple rules to the code we worked out for .swf and .xml and it fixed some mp3 issues.
As for the .css rules, I remember this being the major initial problem I had; and those rules fixed css wrt a custom template set that inherits from luna.

Andy...
Adding
Code:
RewriteRule ^/index.html$ /cgi-bin/links/page.cgi [L]

..just before;

Code:
RewriteRule /?$ /cgi-bin/links/page.cgi [L]

Didn't work. Neither did pugdogs suggestion.

Here it is again if either or both of you are willing to help me finish (or redo) this.
I did just realize that I am no longer able to add ;t=luna for alternate templates, which I thought worked somewhere along the line.
http://www.supportmusicians.com/cgi-bin/links/page.cgi?t=luna gets me to luna template set, but it doesn't "stick".

I'll pay both of you $50 a piece to your paypal accounts if you come to a concensus and help me get this done right.
I was never able to use category naming options without breaking rewrite either fwiw.

Current rules:
Code:
RewriteEngine On
RewriteRule (.*).css $1.css [L]
RewriteRule (.*)\.js $1.js [L]
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.gif $1.gif [L]
RewriteRule (.*)\.jpg $1.jpg [L]
RewriteRule (.*)\.png $1.png [L]
RewriteRule (.*)\.mp3 $1.mp3 [L]
RewriteRule (.*)\.swf $1.swf [L]
RewriteRule (.*)\.xml $1.xml [L]
RewriteRule ^p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]
RewriteRule search/(.*) /cgi-bin/links/search.cgi?query=$1 [L]
RewriteRule jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]
RewriteRule images/(.*) images/$1 [L]
RewriteRule .*L([0-9]+)/?$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule .*L([0-9]+)\.html$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule Detailed/(.*)\.html /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule ^(.*)/index\.html$ /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule ^(.*)/?$ /cgi-bin/links/page.cgi?g=$1/index.html [L]
RewriteRule /?$ /cgi-bin/links/page.cgi [L]


Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Category names and htaccess In reply to
Quote:
Pugdog...
Andy helped me write these rules and I thank him verrry much for doing so.
I duplicated a couple rules to the code we worked out for .swf and .xml and it fixed some mp3 issues.
As for the .css rules, I remember this being the major initial problem I had; and those rules fixed css wrt a custom template set that inherits from luna.


Andy and I see things differently, on the rewrite issue. I've always put things a directory down, and he's kept things up at the top.

If I knew exactly what you were trying to do, I think it can be simplified.

check out:

http://loveatlast.com, http://debtcure.com,

there is a /directory/ then rewritten "static looking" urls.

I don't like serving pages from the "root" of the webserver, except for index.html, because it really "locks" you hard into a layout you can't adapt to given the importance of keeping your search engine links.

Code:
RewriteEngine OnRewriteRule ^/$ /resources/ [R,L,NC]
RewriteRule ^/resources/?$ /resources/

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



The above works on my sites.

it rewrites to an EMPTY directory, called /resources/ on the server, that is set either with .htaccess or in the server config to have the above directory rules.

Once there, any incoming information is rewritten to the page.cgi.

To change your jump/search/etc you would use additional rewrite rules to pick those off first in the root .htaccess.

And, put your images in the /static/ directory in keeping with the new "conceptual" layout. You set your paths in the admin, and that's it.

I had to tweak my navigation bar a bit (but Alex said it wasn't necessary, and in the G3 upgrade, I didn't have to edit the menus).

I didn't even mess with the search/jump issue, but it can be addressed if you'd like. You can also use the /Detailed/(\d+)\.html to display detail pages, if someone knows the link ID.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Category names and htaccess In reply to
Thanks Pugdog.

I think given the choice, I will stick with Alex's directory structure.

So I am back to fixing...

The "Home" link in Navigation bar links to:
http://www.supportmusicians.com/
This works fine.

Crumb links to:
http://www.supportmusicians.com/index.html
and this gives the error of category index not found.

My htaccess
Code:
RewriteEngine On
RewriteRule (.*).css $1.css [L]
RewriteRule (.*)\.js $1.js [L]
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.gif $1.gif [L]
RewriteRule (.*)\.jpg $1.jpg [L]
RewriteRule (.*)\.png $1.png [L]
RewriteRule (.*)\.mp3 $1.mp3 [L]
RewriteRule (.*)\.swf $1.swf [L]
RewriteRule (.*)\.xml $1.xml [L]
RewriteRule ^p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]
RewriteRule search/(.*) /cgi-bin/links/search.cgi?query=$1 [L]
RewriteRule jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]
RewriteRule images/(.*) images/$1 [L]
RewriteRule .*L([0-9]+)/?$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule .*L([0-9]+)\.html$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule Detailed/(.*)\.html /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule ^(.*)/index\.html$ /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule ^(.*)/?$ /cgi-bin/links/page.cgi?g=$1/index.html [L]
RewriteRule /?$ /cgi-bin/links/page.cgi [L]

I wasnt quite sure in your fix where to...
Quote:
Add
RewriteRule ^/index\.html$ /cgi-bin/links/page.cgi [L]

But I did try in a few places, and it didn't work and neither did Alex's one line fix.

I think it best to just help me figure out the domain.com/index.html issue.

Thanks
Chris


RGB World, Inc. - Software &amp; Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Category names and htaccess In reply to
Quote:
I think given the choice, I will stick with Alex's directory structure


That's what I proposed. Links was *never* meant to be installed in the root directory, it defaults to /pages/ unless you override it.

In the 1.x days, there was a lot of discussion on how to make it appear to run from the root, and the solution I proposed, was the one that works, while still allowing links to operate the way it was supposed to, and allowing you to move your server around as needed.

It was actually developed by Alex (using the "empty" directory to force the rewrite), but I've made a few tweaks that make it work just fine for almost any site. Add an "R" here, or remove an "L" there, and you can control exactly what is going on, and what the user sees. I can set up a pseudo dynamic site in about 30 minutes now, just set up http://snorestore.com between replies, and dealing with customers in the store here. This site removes the "R" in the first rewrite, so the person typing in the domain name only, only sees a "/" path (that is where google had originally indexed the static (one page) site, so I need to wait while /snoring/ catches up).

the directory structure you are trying to use is sort of like when a patient comes into the office complaining of a side effect of a medication the doctor just prescribes another medication to deal with the side effect. It's much better to pull off the medications causing a problem, and try again.

As you noticed, the format you are using, while appearing to be "logical" breaks when you try to do something new and different.

What is going to happen a year from now, when those urls' have a solid page rank, and you need to make a change to your site? You could simply disappear.....


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Category names and htaccess In reply to
Pugdog...

I tried to modify your rewrite rules (below), please be more specific.
I do not have access to the config file on the server, so this needs to be done via htaccess

I tried this after creating an empty directory named "music"...
Code:
RewriteEngine OnRewriteRule ^/$ /music/ [R,L,NC]
RewriteRule ^/music/?$ /music/

<Directory /home/virtual/site129/fst/var/www/html/music/>
Options All -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule (.*) /cgi-bin/links/page.cgi?g=$1 [L]
AllowOverride All
Allow From All
</Directory>



My build_root_path is
/home/virtual/site129/fst/var/www/html

My build_root_url is
http://www.supportmusicians.com

My build_static_url is
http://www.supportmusicians.com/static

My db_cgi_url is
http://www.supportmusicians.com/cgi-bin/links

Basic root directory has
/files/
/static/
/static/browser/etc...
/static/fileman/etc...

/static/luna/
/static/luna/luna.css
/static/luna/luna_core.css
/static/luna/images/

/static/terra/
/static/terra/terra.css
/static/terra/images/

All I get is Server 500 errors.

Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Category names and htaccess In reply to
Ok, in case anyone else reads this, these are the (hopefully final) set of mod rewrite rules that I am using at my GLinks 3.x site. They produce urls that look like this...

http://www.domain.com/
http://www.domain.com/index.html
http://www.domain.com/Category/index.html
http://www.domain.com/Category/Subcat/index.html
http://www.domain.com/Detailed/5.html
http://www.domain.com/New/
http://www.domain.com/New/2005-05-15.html

.htaccess
Code:
RewriteEngine On
RewriteRule (.*).css $1.css [L]
RewriteRule (.*)\.js $1.js [L]
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.gif $1.gif [L]
RewriteRule (.*)\.jpg $1.jpg [L]
RewriteRule (.*)\.png $1.png [L]
RewriteRule (.*)\.mp3 $1.mp3 [L]
RewriteRule (.*)\.swf $1.swf [L]
RewriteRule (.*)\.xml $1.xml [L]
RewriteRule ^p/(.*)/? /cgi-bin/links/page.cgi?p=$1 [L]
RewriteRule search/(.*) /cgi-bin/links/search.cgi?query=$1 [L]
RewriteRule jump/(.*) /cgi-bin/links/jump.cgi?ID=$1 [L]
RewriteRule images/(.*) images/$1 [L]
RewriteRule .*L([0-9]+)/?$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule .*L([0-9]+)\.html$ /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule Detailed/(.*)\.html /cgi-bin/links/page.cgi?g=Detailed/$1.html [L]
RewriteRule (.*) /cgi-bin/links/page.cgi?g=$1 [L]
RewriteRule /?$ /cgi-bin/links/page.cgi [L]
RewriteRule ^/index\.html$ /cgi-bin/links/page.cgi [L]
Only tested with 1 level of subcategories.

Chris
RGB World, Inc. - Software &amp; Web Development.
rgbworld.com