HowTo on making PHPMyFAQ spiderable. (static pages)

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

nickn
Posts: 23
Joined: Mon Mar 15, 2004 5:58 pm

HowTo on making PHPMyFAQ spiderable. (static pages)

Post by nickn »

Here is a HowTo on making your PHPMyFAQ completely indexable by search engines. This is in use on www.cpanelfaq.com, as you can see by going to google and typing "site:cpanelfaq.com" you will see that almost every page of my FAQ is indexed already.

I've detailed what every rule does, as well as attached my functions.php, please note that there are changes that need to be made in this file as I made most of the URLs independant to my site (due to lack of PHP skills)

Here is the fucntions.phps:

http://www.cpanelfaq.com/downloads/functions.phps

I am not a PHP coder, we hope to see this stuff put into the FAQ as an option in the future, until than...this is mostly for Thorsten to reference.

Rewrite Rules I used to make PHPMyFAQ searchable, I've detailed what each one is for under the rule:

The below rules are normal rules neccessary to turn on the rewrite engine, and log appropriately

Code: Select all

RewriteEngine On
RewriteLog "/home/cpfaq/public_html/rewrite.log"
RewriteLogLevel 2
Options +FollowSymLinks
Rewrites http://www.example.com/001/3.html to http:///index.php?aktion=artikel&rubrik=001&id=2&lang=en

Code: Select all

RewriteRule ^/([0-9]+)/([0-9]+)\.html /index.php?aktion=artikel&rubrik=$1&id=$2&lang=en [L]
Rewrites http://www.example.com/sitemap001.html to http://www.example.com/index.php?aktion=sitemap001 , this simply allows me to create another HTML page that contains nothing but links to each catagory, each page contains all links for catagory

Code: Select all

RewriteRule ^/[Ss][Ii][Tt][Ee][Mm][Aa][Pp]([0-9]+)\.html$ /index.php?aktion=sitemap$1 [L]
Rewrites http://www.example.com/sitemap.html to http://www.example.com/index.php?aktion=sitemap, this page simply holds all the links for the different sitemaps for each catagory, I created a link to this page on the main page

Code: Select all

RewriteRule ^/[Ss][Ii][Tt][Ee][Mm][Aa][Pp]\.html$ /index.php?aktion=sitemap [L]
Rewrites http://www.example.com/003/index.html to the main catagory page at http:///www.example.com//index.php?aktion=anzeigen&rubrik=003

Code: Select all

RewriteRule ^/([0-3][0-3][0-9])/[Ii][Nn][Dd][Ee][Xx]\.html /index.php?aktion=anzeigen&rubrik=$1 [L]
Rewrites http://www.example.com/showcat.html to http://www.example.com/index.php?aktion=anzeigen which is the page that shows all catagories

Code: Select all

ReWriteRule ^/[Ss][Hh][Oo][Ww][Cc][Aa][Tt]\.html$ /index.php?aktion=anzeigen [L]

The below rules are not absolutely neccessary, but it makes the site 100% static. What they do is very obvious:

Code: Select all

ReWriteRule ^/[Ss][Ee][Aa][Rr][Cc][Hh]\.html$ /index.php?aktion=search [L]
ReWriteRule ^/[Aa][Dd][Dd][Cc][Oo][Nn][Tt][Ee][Nn][Tt]\.html$ /index.php?aktion=add [L]
ReWriteRule ^/[Aa][Ss][Kk]\.html$ /index.php?aktion=ask [L]
ReWriteRule ^/[Oo][Pp][Ee][Nn]\.html$ /index.php?aktion=open [L]
ReWriteRule ^/[Hh][Ee][Ll][Pp]\.html$ /index.php?aktion=hilfe [L]
ReWriteRule ^/[Cc][Oo][Nn][Tt][Aa][Cc][Tt]\.html$ /index.php?aktion=kontakt [L]
All the rules together:

Code: Select all

RewriteEngine On
RewriteLog "/home/cpfaq/public_html/rewrite.log"
RewriteLogLevel 2
Options +FollowSymLinks
RewriteRule ^/([0-9]+)/([0-9]+)\.html /index.php?aktion=artikel&rubrik=$1&id=$2&lang=en [L]
RewriteRule ^/[Ss][Ii][Tt][Ee][Mm][Aa][Pp]([0-9]+)\.html$ /index.php?aktion=sitemap$1 [L]
RewriteRule ^/[Ss][Ii][Tt][Ee][Mm][Aa][Pp]\.html$ /index.php?aktion=sitemap [L]
RewriteRule ^/([0-3][0-3][0-9])/[Ii][Nn][Dd][Ee][Xx]\.html http://www.cpanelfaq.com/index.php?aktion=anzeigen&rubrik=$1 [L]
ReWriteRule ^/[Ss][Hh][Oo][Ww][Cc][Aa][Tt]\.html$ /index.php?aktion=anzeigen [L]
ReWriteRule ^/[Ss][Ee][Aa][Rr][Cc][Hh]\.html$ /index.php?aktion=search [L]
ReWriteRule ^/[Aa][Dd][Dd][Cc][Oo][Nn][Tt][Ee][Nn][Tt]\.html$/index.php?aktion=add [L]
ReWriteRule ^/[Aa][Ss][Kk]\.html$ /index.php?aktion=ask [L]
ReWriteRule ^/[Oo][Pp][Ee][Nn]\.html$ /index.php?aktion=open [L]
ReWriteRule ^/[Hh][Ee][Ll][Pp]\.html$ /index.php?aktion=hilfe [L]
ReWriteRule ^/[Cc][Oo][Nn][Tt][Aa][Cc][Tt]\.html$ /index.php?aktion=kontakt [L]
Any questions, don't hesitate to let me know :)
Last edited by nickn on Fri Apr 02, 2004 3:26 am, edited 2 times in total.
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi Nick,

thanks for your work. I'll include this in one of the neyt version of phpMyFAQ!

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
dmsinger
Posts: 2
Joined: Mon Jun 07, 2004 4:51 pm

Post by dmsinger »

* edit - removing my suggestion for the moment until I surf around more :)
dmsinger
Posts: 2
Joined: Mon Jun 07, 2004 4:51 pm

Post by dmsinger »

Ok, my question is - is it possible to have mod_rewrite used to create links that don't have the .html extension?

Like:
http://www.example.com/contact
http://www.example.com/003
http://www.example.com/001/3
nickn
Posts: 23
Joined: Mon Mar 15, 2004 5:58 pm

Post by nickn »

Sure...

What are you trying to rewrite it too? Give me the new (shorter) URL and the URL that you want to rewrite too (ie the default..old.. URL)
Gastongr
Posts: 13
Joined: Mon Jul 19, 2004 12:32 am

Post by Gastongr »

How do i apply this to my site?
i mean where should i put the Rewrite rules. And what about functions.php?

I tryed putting the rules in the .htaccess file and replaceing my functions.php with the one you posted (i changed the urls) but it doesn't work.

I'd really appresiate your help

Thanks Gaston
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

does your webserver support mod_rewrite?

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Gastongr
Posts: 13
Joined: Mon Jul 19, 2004 12:32 am

Post by Gastongr »

I think it does because i'm using some rewrite rules in other site hosted in the same account. the htaccess file i use in that site is this

Code: Select all

RewriteEngine On 
RewriteRule ^forums.* index.php [L,NC]
RewriteRule ^post-([0-9]*).html&highlight=([a-zA-Z0-9]*) viewtopic.php?p=$1&highlight=$2 [L,NC]
RewriteRule ^post-([0-9]*).* viewtopic.php?p=$1 [L,NC]
RewriteRule ^view-poll([0-9]*)-([0-9]*)-([a-zA-Z]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&vote=viewresult [L,NC]
RewriteRule ^about([0-9]*).html&highlight=([a-zA-Z0-9]*) viewtopic.php?t=$1&highlight=$2 [L,NC]
RewriteRule ^about([0-9]*).html&view=newest viewtopic.php?t=$1&view=newest [L,NC]
RewriteRule ^about([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4 [L,NC]
RewriteRule ^about([0-9]*)-([0-9]*).* viewtopic.php?t=$1&start=$2 [L,NC]
RewriteRule ^about([0-9]*).* viewtopic.php?t=$1 [L,NC]
RewriteRule ^about([0-9]*).html viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5 [L,NC]
RewriteRule ^mark-forum([0-9]*).html* viewforum.php?f=$1&mark=topics [L,NC]
RewriteRule ^updates-topic([0-9]*).html* viewtopic.php?t=$1&watch=topic [L,NC]
RewriteRule ^stop-updates-topic([0-9]*).html* viewtopic.php?t=$1&unwatch=topic [L,NC]
RewriteRule ^forum-([0-9]*).html viewforum.php?f=$1 [L,NC]
RewriteRule ^forum-([0-9]*).* viewforum.php?f=$1 [L,NC]
RewriteRule ^topic-([0-9]*)-([0-9]*)-([0-9]*).* viewforum.php?f=$1&topicdays=$2&start=$3 [L,NC]
RewriteRule ^ptopic([0-9]*).* viewtopic.php?t=$1&view=previous [L,NC]
RewriteRule ^ntopic([0-9]*).* viewtopic.php?t=$1&view=next [L,NC]
[/quote]
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

These are not the rules for phpMyFAQ 1.3.x.....

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
Gastongr
Posts: 13
Joined: Mon Jul 19, 2004 12:32 am

Post by Gastongr »

I know they'r not for phpmyfaq but i used them succesfully for other script in my webserver, so i think the server supports mod_rewrite.
I was answering your question
does your webserver support mod_rewrite?
Yes it does.
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

okay.

Since I did not write this hack I cannot say anything about that. Sorry. Please send an e-mal to the author of the hack.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
brakai295
Posts: 18
Joined: Mon Aug 09, 2004 7:08 am

Post by brakai295 »

Hi!

Very interesting this thread! I'm looking for a script that makes my FAQ spiderable. But I'm using 1.4.1.

Is there anyone that has tried to implement to script above in the 1.4.* version?

Cheers
Kai
Thorsten
Posts: 15725
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Post by Thorsten »

Hi,

as written in another thread I will port the mod_rewrite support to 1.4.2.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
nickn
Posts: 23
Joined: Mon Mar 15, 2004 5:58 pm

Post by nickn »

Thorsten,

Will it be included in the actual application? or just hacks like I created?

Looking forward to 1.4.2, getting ready to start another site using phpmyfaq[/code]
nickn
Posts: 23
Joined: Mon Mar 15, 2004 5:58 pm

Post by nickn »

Did you happen to get around to doing this yet? Very interested in this feature so I don't have to hack up a custom patch again....causes issues when upgrading, etc..
Post Reply