Gossamer Forum
Home : Products : Gossamer Links : Discussions :

rewrite rules question

Quote Reply
rewrite rules question
Hello all, sorry to ask this, but i'm just trying to figure out myself about the rewrite mod rules for my site.

As i want to use links on dynamic mode... I'm trying to use this rules:

RewriteEngine On
RewriteRule (.*)\.css $1.css [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^AddImages/(.*) AddImages/$1 [L]
RewriteRule ^Images/(.*) Images/$1 [L]
RewriteRule ^p/(.*) /cgi-bin/choulinks/page.cgi?g=$1 [L]
RewriteRule ^info/(.*) /cgi-bin/choulinks/page.cgi?p=$1 [L]
RewriteRule ^(.*).html /cgi-bin/choulinks/page.cgi?g=$1.html [L]
RewriteRule ^$ /cgi-bin/choulinks/page.cgi [L]

I'm still doing tests with my links installation, so i'm only seeing my pages from the admin menu, using the dynamic link there. However my pages still looks this this:

/page.cgi?g=Arts___Entretainment%2Findex.html&d=1

My .htaccess file its located on my html directory. My site structure its like this:

cgi-bin
choulinks
html
images
new
cool

Where exactly do i need to upload the .htaccess file? (cgi-bin or html directories)? and I took this rules as my base, from a rule posted by Andy on this forums.

Any help or advice on this will be really appreciate it :)

Hovwer, I'm still searchoing and looking for more info on this.

Jesus
Quote Reply
Re: [Jesus] rewrite rules question In reply to
Hi,

You need to view your site statically - not dynamically. The rewrite rules rules should take your static links and change them to dynamic ones.

To test whether they are working, try changing the [L] to [R] (just for testing). You should then be able to type a static link into your browser address bar and see it change to the correct dynamic address.

I'm not sure that I agree that this is the best set of rewrite rules for a general site. In particular, this rule
RewriteRule ^(.*).html /cgi-bin/choulinks/page.cgi?g=$1.html [L]
will not allow you to have any static html pages in your site. I can't see what the first four rules achieve - maybe Andy could explain why he is using them Wink.

I would think something like this would be enough - where /links/ is the directory that you are using for your links installation.

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

RewriteRule ^$ /cgi-bin/choulinks/page.cgi [L]
RewriteRule ^/p/(.*)$ /cgi-bin/choulinks/page.cgi?p=$1 [L]
RewriteRule ^/links/(.*)$ /cgi-bin/choulinks/page.cgi?g=$1 [L]
Quote Reply
Re: [afinlr] rewrite rules question In reply to
Quote:
I can't see what the first four rules achieve - maybe Andy could explain why he is using them .

They are catch-alls for my site. I was having problems with images not showing up, so I added those in to stop these problems. As you say, it varies for each site, so whats good for one site, may not be what you need on another :)

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] rewrite rules question In reply to
Andy,
I was going to ask about this as well. I am currently using your rewrite rules. But I had to put the htaccess in lsql subdirectory. (ex mysite.com/guide) because of the problem with static page that aflnr mentioned.

I also tried pugdog rules but couldn't get it to work at all.
I'd like to just have the lsql rules in my root htaccess. Could you walk through what each rule does so I can figure out what I need?

Thanks
ccunet
my Christian web
Quote Reply
Re: [ccunet] rewrite rules question In reply to
Unfortunatly its not just something that can be walked through, as it differs for each installation. I'm far from an expert in mod_rewrite, and can just about put a .htaccess file together. Maybe Laura could give some advice on the matter?

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] rewrite rules question In reply to
Try the below;

Code:
RewriteEngine on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^/images/(.*)$ /images/$1 [L]
RewriteRule ^$ /cgi-bin/choulinks/page.cgi [L]
RewriteRule ^/p/(.*)$ /cgi-bin/choulinks/page.cgi?p=$1 [L]
RewriteRule ^/links/(.*)$ /cgi-bin/choulinks/page.cgi?g=$1 [L]

Thats why I had that part in my mod_rewrite Wink

Cheers
my Christian web

Last edited by:

Andy: Apr 26, 2004, 7:03 AM
Quote Reply
Re: [ccunet] rewrite rules question In reply to
You need to say where your images are actually located and the url that you use to link to them. For example, if your image directory is /icons but all your links to images in your templates point to /images then you would need a rewrite rule something like this:

RewriteRule ^/images/(.*)$ /icons/$1 [L]
Quote Reply
Re: [ccunet] rewrite rules question In reply to
Note, if you've been using Andy's image rules and they worked, just add them back in to this set. As I said, I don't understand what they're doing but if they work - why not use them Wink.
Quote Reply
Re: [afinlr] rewrite rules question In reply to
In Reply To:
Note, if you've been using Andy's image rules and they worked, just add them back in to this set. As I said, I don't understand what they're doing but if they work - why not use them Wink.

See, I always put stuff in for a reason Tongue (well, most of the time...lol).

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: [Jesus] rewrite rules question In reply to
Thank you all for your contributions to this. I'll try tonight to improve all this and hopefully i'll make it work :)

I'll keep you all posted.

Again thanks :)

Jesus