Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Any mod re-write Insturctions for dummies!!!

Quote Reply
Any mod re-write Insturctions for dummies!!!
I've read about mod-rewrite here and there... however, I would love to see a step-by-step instructions on how to create the mod, where to put it, and what is suppose to be in it.. .
I installed the regular Links 3.x (dynamic mode) along with page builder...
but the user always goes to:
http://.../cgi-bin/link/page.cgi?d=1 to see the site.. where I really want the visitor to just access the main domain to see the site...
How do I do that on LAMP considering also my images are in .../image/ and have robots file in the root .../robots.txt
Thanks much in advance ..
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

This is what I tend to use in the .htaccess file ( in the /www/ folder, or wheverever you want the pages to show);

Code:
RewriteEngine On

RewriteRule ^$ /cgi-bin/page.cgi?g=index.html [L]
RewriteRule ^/$ /cgi-bin/page.cgi?g=index.html [L]
RewriteRule ^index.html$ /cgi-bin/page.cgi?g=index.html [L]

# CSS/images/other page type rewrites, so they get shown, instead of page.cgi picking them up
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.php $1.php [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^static/(.*) static/$1 [L]


# stuff so you can call custom templates via yoursite.com/g-template_name.html
RewriteRule ^g-(.*).html? /cgi-bin/page.cgi?p=$1 [L]
RewriteRule ^g-(.*)/? /cgi-bin/page.cgi?p=$1 [L]
RewriteRule ^images/(.*) images/$1 [L]

# detailed pages rewrite
RewriteRule ^Detailed/([0-9]+)\.html$ /cgi-bin/page.cgi?g=Detailed/$1.html [L]
RewriteRule ^.*L([0-9]+)/(.*)\.html$ /cgi-bin/page.cgi?g=Detailed/$1.html [L]
RewriteRule ^.*L([0-9]+)/?$ /cgi-bin/page.cgi?g=Detailed/$1.html [L]

# New, Pop, Ratings etc rewrite rules
RewriteRule ^New/?$ /cgi-bin/page.cgi?g=New [L]
RewriteRule ^Ratings/?$ /cgi-bin/page.cgi?g=Ratings [L]
RewriteRule ^Cool/?$ /cgi-bin/page.cgi?g=Cool [L]

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

# more page rewrite rule
RewriteRule ^(.*)/more([0-9]+)\.html$ /cgi-bin/page.cgi?g=$1/more$2.html [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: [Andy] Any mod re-write Insturctions for dummies!!! In reply to
Thanks very much Andy.. you are always very helpful...Angelic

Mark
Quote Reply
Re: [Andy] Any mod re-write Insturctions for dummies!!! In reply to
Hello again,
I used your re-write rules and seems to work except I have a bit different layouts fo directories and plugins.
I still have these issues:

1- The location of Plugins is not being covered in your .htaccess, as somehow, they give errors on the pages that they are called from.
2- My directory structure is: ...cgi-bin/scripts/admin/...etc.), and my templates are inside a new directory called "ads" (not "luna") .. so I need to note this one.
3- I have 10 extra CSS files located inside a CSS directory called "ads" also (not "luna") in the admin .. I need to point the location of these CSS files in the rules.
4 - PageBuilder pages seem to switch the pages to dynamic mode calls like: /cgi-bin/scripts/page.cgi?page=copyright;d=1 instead of re-write rule calls... so how can I create a rule so they can be called like any category or other pages...
5- I need to create a file in www/ called robots.txt .... how can I call it in the .htaccess...
6- I need to create a rule for the following line (it is a paging code to navigate through the same category):
Note: I called "more" as "next" and use .php extension for all my files (except templates).

Code:
<a href="<%db_cgi_url%>/page.cgi?g=<%category_id%>/next<%if paging.current_page%><%paging.current_page + 1%><%else%>2<%endif%>.php;d=1">
7- Any other suggestions or recommendations?!?!?!

Any help in re-writting these rules is truly appreciated....
Thanks much again...
Mark

Last edited by:

Mark2: Aug 10, 2008, 3:43 PM
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

I need some example URL's, so I can see whats going on ;)

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] Any mod re-write Insturctions for dummies!!! In reply to
Hello Andy,
The site is still under constructions syriacredit.net and developing it locally...
It is really hard to point you to a particular example/link as it is very customized (including the all admin screens)...
so I was just wondering if it is possibly to see how can I address these issues..
Thanks much again..
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

I'm afraid I can't really comment on a lot of them - as its hard to even see what your talking about, without seeing it =)

Re PageBuilder - that .htaccess code doesn't even address that page.cgi?page=xxx function - so not sure whats going on there ;)

Quote:
3- I have 10 extra CSS files located inside a CSS directory called "ads" also (not "luna") in the admin .. I need to point the location of these CSS files in the rules.

That should work:

RewriteRule (.*)\.css $1.css [L]

Quote:
5- I need to create a file in www/ called robots.txt .... how can I call it in the .htaccess...

You **could** try this :

Code:
RewriteRule robots.txt /www/robots.txt [L]

Can you just paste your .htaccess file, so I can see if you've made changes?

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] Any mod re-write Insturctions for dummies!!! In reply to
This is what I have in my .htaccess... it is as you listed (I think).
But still somehow not all CSS files are called.


Code:
RewriteEngine On

RewriteRule ^$ /cgi-bin/scripts/page.cgi?g=index.php [L]
RewriteRule ^/$ /cgi-bin/scripts/page.cgi?g=index.php [L]
RewriteRule ^index.html$ /cgi-bin/scripts/page.cgi?g=index.php [L]

# CSS/images/other page type rewrites, so they get shown, instead of page.cgi picking them up
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.php $1.php [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^static/(.*) static/$1 [L]

# stuff so you can call custom templates via yoursite.com/g-template_name.html
RewriteRule ^g-(.*).html? /cgi-bin/scripts/page.cgi?p=$1 [L]
RewriteRule ^g-(.*)/? /cgi-bin/scripts/page.cgi?p=$1 [L]
RewriteRule ^images/(.*) images/$1 [L]

# detailed pages rewrite
RewriteRule ^Detailed/([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=Detailed/$1.php [L]
RewriteRule ^.*L([0-9]+)/(.*)\.php$ /cgi-bin/scripts/page.cgi?g=Detailed/$1.php [L]
RewriteRule ^.*L([0-9]+)/?$ /cgi-bin/scripts/page.cgi?g=Detailed/$1.php [L]

# New, Pop, Ratings etc rewrite rules
RewriteRule ^New/?$ /cgi-bin/scripts/page.cgi?g=New [L]
RewriteRule ^Ratings/?$ /cgi-bin/scripts/page.cgi?g=Ratings [L]
RewriteRule ^Cool/?$ /cgi-bin/scripts/page.cgi?g=Cool [L]

# category page rewrite
RewriteRule ^(.*)/index\.php$ /cgi-bin/scripts/page.cgi?g=$1/index.php [L]

# more page rewrite rule
RewriteRule ^(.*)/next([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=$1/next$2.php [L]


Also, I am getting this error on one of the pages (as it calles a plugin) which maybe it is not seeing it (but works in dynamic mode):
Code:


Error: Unable to load module 'Plugins::Coregs_New':

Can't locate Plugins/Coregs_New.pm in @INC (@INC contains: /home/syriacredit/www/cgi-bin/scripts/admin /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at GT::Template::_call_func line 731. ,
Can't locate Plugins.pm in @INC (@INC contains: /home/www/syriacredit/cgi-bin/scripts/admin /usr/lib/perl5/5.6.1/i386-linux /usr/lib/perl5/5.6.1 /usr/lib/perl5/site_perl/5.6.1/i386-linux /usr/lib/perl5/site_perl/5.6.1 /usr/lib/perl5/site_perl/5.6.0/i386-linux /usr/lib/perl5/site_perl/5.6.0 /usr/lib/perl5/site_perl .) at GT::Template::_call_func line 731.

So, not sure if I am missing rules here and there...
Thanks
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

Re CSS, try adding:

Code:
RewriteRule ^ads/(.*) ads/$1 [L]

..after:

Code:
RewriteRule ^static/(.*) static/$1 [L]

Regarding the plugins - is that Plugin DEFINALTY spelt right?

The .htaccess stuff shouldn't affect anythingat all in the /cgi-bin folder.

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] Any mod re-write Insturctions for dummies!!! In reply to
Hello,
The statement did not make a difference; however, I've noticed all directories in the www/ are created as numbers: (1, 2, 3, 4....etc. ) and inside them is /1/index.php /2/index.php ....etc...
So I was wondering, when I type www.mydomain.com ... it seems I am calling the static pages not the dynamic ones (that are converted by mod re-write to behaive like static pages)...
So I am not really sure which page I am calling (the existing static one, or the one called by the rules)...
If I delete all the static directories (1,2,3,... ) will the .htacess works... ?
do I need to put the .htacess any place other then www/

thank you...
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

I would normally put the codes into the www/.htaccess file, or in your domain.conf file.

Its not very easy debugging a site's .htaccess without being able to access the site / see the problems - so I'm afraid there isn't really much more help I can offer (not to mention the fact I'm up to my eye balls in work ATM,so barley have enough time to even check the forum =))

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] Any mod re-write Insturctions for dummies!!! In reply to
Thanks anyway Andy.. you've been very helpful all the time.. and I truely appreciate all the help that you've already gave me...

Thanks again
Mark
Quote Reply
Re: [Andy] Any mod re-write Insturctions for dummies!!! In reply to
Hi Andy,
I looked at one of your posts where it says u can not use .php as an extension for dynamic mod (page.cgi) when u want to use mod_rewrite.
My question, I use .php extention as the extenstion of my dynamic website.. so:
- Should I change all the extensions per your thread to .html so mod_rewrite works?
http://www.gossamer-threads.com/...%20.htaccess;#275263
so make build page extention from the admin as: *.html

- Should I delete all static pages that i build so I can use mod_rewrite to make dynamic pages behave like statics...
so if I type www.mydomain.com it calls page.cgi?d=1

Thanks and sorry to bother u again...
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

You can use .php as an extension, but IF its being run via mod_rewrite, then doing stuff like:

<?php do_something() ?>

..won't work - as they are being parsed by Perl, and not PHP.

The only way to do "includes"/run PHP commands, is with something like:

exec_php
Code:
sub {
my $cmd = `/usr/bin/php $_[0]`;
return $cmd;
}

..then call with:

<%ecec_php('/path/to/script.php'')%>

Personally - I would change to .html - as having .php serves no real reason, cos they can't do the same as a file.php =)

Quote:
- Should I delete all static pages that i build so I can use mod_rewrite to make dynamic pages behave like statics...
so if I type www.mydomain.com it calls page.cgi?d=1

Well, you can delete the files generated via nph-build.cgi - but be careful not to delete files you may still need (i.e /static/ etc).. otherwise you will have headaches later on =)

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] Any mod re-write Insturctions for dummies!!! In reply to
Thanks again Andy...
I've deleted all related directories, and now when I call the home page it comes up; however, when I click on any directory to points to ...mydomain.com/43/index.php or something like that...
so do I have to create a rule for each directory and each page inside it..

thank you again ang again...
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

Try adding:

RewriteRule /([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=Detailed/$1/index.php [L]
RewriteRule /([0-9]+)/more([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=Detailed/$1/more$2.php [L]

...that should work

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] Any mod re-write Insturctions for dummies!!! In reply to
Somehow it did not work in my case....
I use *.php extension in the admin, and use (next instead of more) for extended pages .. the rest are all the same...
Is there any generic re-write mod the allow the user to access the site, navigate, search, ...etc. for dynamic site and looks like it is a static...?
What i have now is listed below.. but somehow it works only for the mydomain.com .. and the rest dead links:

Code:
RewriteEngine On
RewriteRule ^$ /cgi-bin/scripts/page.cgi?g=index.php [L]
RewriteRule ^/$ /cgi-bin/scripts/page.cgi?g=index.php [L]
RewriteRule ^index.php$ /cgi-bin/scripts/page.cgi?g=index.php [L]

# CSS/images/other page type rewrites, so they get shown, instead of page.cgi picking them up
RewriteRule (.*)\.css $1.css [L]
RewriteRule (.*)\.php $1.php [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^banners/(.*) /banners/$1 [L]
RewriteRule ^static/(.*) static/$1 [L]
RewriteRule ^ads/(.*) ads/$1 [L]

# stuff so you can call custom templates via yoursite.com/g-template_name.html
RewriteRule ^g-(.*).html? /cgi-bin/scripts/page.cgi?p=$1 [L]
RewriteRule ^g-(.*)/? /cgi-bin/scripts/page.cgi?p=$1 [L]
RewriteRule ^images/(.*) images/$1 [L]
RewriteRule ^banners/(.*) /banners/$1 [L]

# detailed pages rewrite
RewriteRule ^Detailed/([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=Detailed/$1.php [L]
RewriteRule ^.*L([0-9]+)/(.*)\.php$ /cgi-bin/scripts/page.cgi?g=Detailed/$1.php [L]
RewriteRule ^.*L([0-9]+)/?$ /cgi-bin/scripts/page.cgi?g=Detailed/$1.php [L]

# New, Pop, Ratings etc rewrite rules
RewriteRule ^New/?$ /cgi-bin/scripts/page.cgi?g=New [L]
RewriteRule ^Ratings/?$ /cgi-bin/scripts/page.cgi?g=Ratings [L]
RewriteRule ^Cool/?$ /cgi-bin/scripts/page.cgi?g=Cool [L]

# category page rewrite
RewriteRule ^(.*)/index\.php$ /cgi-bin/scripts/page.cgi?g=$1/index.php [L]

# more page rewrite rule
RewriteRule ^(.*)/next([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=$1/next$2.php [L]

RewriteRule /([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=$1/index.php [L]
RewriteRule /([0-9]+)/next([0-9]+)\.php$ /cgi-bin/scripts/page.cgi?g=$1/next$2.php [L]
~


Thanks much
Mark
Quote Reply
Re: [Mark2] Any mod re-write Insturctions for dummies!!! In reply to
Hi,

The code I gave you should work fine. I'm using it on hundreds of sites.

Without seeing anything on a live domain, there is only a limited amount of time I can dedicate to this - sorry :(

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!