Monday, May 30, 2011

Knowing How The SEFURL in Tiki Works



You have known Tiki SEFURL already in the previous tips. Tiki stores the SEFURL records internally in the table named tiki_sefurl_regex_out of Tiki database. On the other side, externally, Tiki has created file named _htaccess, which works in the APACHE environment (Server side. To get this _htaccess works, rename it to .htaccess.) To get the SEFURL works, both file .htaccess and table tiki_sefurl_regex_out must be matched together.

The table below shows the relation between file .htaccess and table tiki_sefurl_regex_out.

Table: tiki_sefurl_regex_out file: .htaccess
id left right
    1  tiki-index.php\?page=(.+)   $1   RewriteRule ^(.+)$    tiki-index.php?page=$1 [QSA,L] 
    2  tiki-slideshow.php\?page=(.+)   show:$1   RewriteRule ^show:(~?)(.+)$   tiki-slideshow.php?page=$1$2 [QSA,L] 
    3  tiki-read_article.php\?articleId=(\d+)   article$1   RewriteRule ^article([0-9]+)(.*)   tiki-read_article.php?articleId=$1$2 [QSA,L] 
    4  tiki-browse_categories.php\?parentId=(\d+)   cat$1   RewriteRule ^cat([0-9]+)(.*)   tiki-browse_categories.php?parentId=$1$2 [QSA,L] 
    5  tiki-view_blog.php\?blogId=(\d+)   blog$1   RewriteRule ^blog([0-9]+)(.*)   tiki-view_blog.php?blogId=$1$2 [QSA,L] 
    6  tiki-view_blog_post.php\?postId=(\d+)   blogpost$1   RewriteRule ^blogpost([0-9]+)(.*)    tiki-view_blog_post.php?postId=$1$2 [QSA,L] 
    7  tiki-browse_image.php\?imageId=(\d+)   browseimage$1   RewriteRule ^browseimage([0-9]+)(.*)   tiki-browse_image.php?imageId=$1$2 [QSA,L] 
    8  tiki-directory_browse.php\?parent=(\d+)   directory$1   RewriteRule ^directory([0-9]+)(.*)   tiki-directory_browse.php?parent=$1$2 [QSA,L] 
    9  tiki-view_faq.php\?faqId=(\d+)   faq$1   RewriteRule ^faq([0-9]+)(.*)   tiki-view_faq.php?faqId=$1$2 [QSA,L] 
  10  tiki-download_file.php\?fileId=(\d+)   dl$1   RewriteRule ^dl([0-9]+)(.*)   tiki-download_file.php?fileId=$1$2 [QSA,L] 
  11  tiki-download_file.php\?fileId=(\d+)&thumbnail   thumbnail$1   RewriteRule ^thumbnail([0-9]+)(.*)   tiki-download_file.php?fileId=$1&thumbnail$2 [QSA,L] 
  12  tiki-download_file.php\?fileId=(\d+)&display   display$1   RewriteRule ^display([0-9]+)(.*)   tiki-download_file.php?fileId=$1&display$2 [QSA,L] 
  13  tiki-download_file.php\?fileId=(\d+)&preview   preview$1   RewriteRule ^preview([0-9]+)(.*)   tiki-download_file.php?fileId=$1&preview$2 [QSA,L] 
  14  tiki-view_forum.php\?forumId=(\d+)   forum$1   RewriteRule ^forum([0-9]+)(.*)   tiki-view_forum.php?forumId=$1$2  [QSA,L] 
  15  tiki-browse_gallery.php\?galleryId=(\d+)   gallery$1   RewriteRule ^gallery([0-9]+)(.*)   tiki-browse_gallery.php?galleryId=$1$2 [QSA,L] 
  16  show_image.php\?id=(\d+)   image$1   RewriteRule ^image([0-9]+)(.*) show_image.php?id=$1$2 [QSA,L] 
  17  show_image.php\?id=(\d+)&scalesize=(\d+)   imagescale$1/$2   RewriteRule ^imagescale([0-9]+)/([0-9]+)(.*) show_image.php?id=$1&scalesize=$2$3  [QSA,L] 
  18  tiki-newsletters.php\?nlId=(\d+)   newsletter$1   RewriteRule ^newsletter([0-9]+)(.*)   tiki-newsletters.php?nlId=$1$2&info=1 [QSA,L] 
  19  tiki-take_quiz.php\?quizId=(\d+)   quiz$1   RewriteRule ^quiz([0-9]+)(.*)   tiki-take_quiz.php?quizId=$1$2 [QSA,L] 
  20  tiki-take_survey.php\?surveyId=(\d+)   survey$1   RewriteRule ^survey([0-9]+)(.*)   tiki-take_survey.php?surveyId=$1$2 [QSA,L] 
  21  tiki-view_tracker.php\?trackerId=(\d+)   tracker$1   RewriteRule ^tracker([0-9]+)(.*)   tiki-view_tracker.php?trackerId=$1$2 [QSA,L] 
  22  tiki-integrator.php\?repID=(\d+)   int$1   RewriteRule ^int([0-9]+)(.*)   tiki-integrator.php?repID=$1$2 [QSA,L] 
  23  tiki-view_sheets.php\?sheetId=(\d+)   sheet$1   RewriteRule ^sheet([0-9]+)(.*)   tiki-view_sheets.php?sheetId=$1$2 [QSA,L] 
  24  tiki-directory_redirect.php\?siteId=(\d+)   dirlink$1   RewriteRule ^dirlink([0-9]+)   tiki-directory_redirect.php?siteId=$1 [QSA,L] 
  32  tiki-calendar.php   calendar   RewriteRule ^calendar$   tiki-calendar.php  [L] 
  33  tiki-view_articles.php   articles   RewriteRule ^articles$   tiki-view_articles.php [L] 
  34  tiki-list_blogs.php   blogs   RewriteRule ^blogs$   tiki-list_blogs.php [L] 
  35  tiki-browse_categories.php   categories   RewriteRule ^categories$   tiki-browse_categories.php [L] 
  36  tiki-contact.php   contact   RewriteRule ^contact$    tiki-contact.php [L] 
  37  tiki-directory_browse.php   directories   RewriteRule ^directories$   tiki-directory_browse.php [L] 
  38  tiki-list_faqs.php   faqs   RewriteRule ^faqs$    tiki-list_faqs.php [L] 
  39  tiki-file_galleries.php   files   RewriteRule ^filelist$   tiki-list_file_gallery.php [L] 
  40  tiki-forums.php   forums   RewriteRule ^forums$   tiki-forums.php [L] 
  41  tiki-galleries.php   galleries   RewriteRule ^galleries$   tiki-galleries.php [L] 
  42  tiki-login_scr.php   login   RewriteRule ^login$   tiki-login_scr.php [L] 
  43  tiki-my_tiki.php   my   RewriteRule ^my$   tiki-my_  tiki.php [L] 
  44  tiki-newsletters.php   newsletters   RewriteRule ^newsletters$   tiki-newsletters.php [L] 
  45  tiki-list_quizzes.php   quizzes   RewriteRule ^quizzes$    tiki-list_quizzes.php [L] 
  46  tiki-stats.php   stats   RewriteRule ^stats$   tiki-stats.php [L] 
  47  tiki-list_surveys.php   surveys   RewriteRule ^surveys$    tiki-list_surveys.php [L] 
  48  tiki-list_trackers.php   trackers   RewriteRule ^trackers$   tiki-list_trackers.php [L] 
  49  tiki-mobile.php   mobile   RewriteRule ^mobile$   tiki-mobile.php [L] 
  50  tiki-sheets.php   sheets   RewriteRule ^sheets$   tiki-sheets.php [L] 
  52  tiki-view_tracker_item.php\?itemId=(\d+)   item$1   RewriteRule ^item([0-9]+)(.*)   tiki-view_tracker_item.php?itemId=$1$2 [QSA,L] 
  53  tiki-list_file_gallery.php\?galleryId=(\d+)   file$1   RewriteRule ^file([0-9]+)(.*)   tiki-list_file_gallery.php?galleryId=$1$2 [QSA,L] 
  54  tiki-user_information.php\?userId=(\d+)   user$1   RewriteRule ^user([0-9]+)(.*)   tiki-user_information.php?userId=$1$2 [QSA,L] 

The column right is the friendly URL name while the column left is the PHP file name where the friendly URL should be executed in the table tiki_sefurl_regex_out. The file .htaccess rewrites the PHP file name with rule that must be preceded by an " ^ " sign as the friendly URL.

For example, id #49, tiki-mobile.php has the same friendly URL, i.e. mobile. Thus, typing http://www.example.com/mobile will redirect URL to http://www.example.com/tiki-mobile.php. Both http://www.example.com/mobile and http://www.example.com/tiki-mobile.php are identical. The difference is that http://www.example.com/mobile is easier to be identified by Search Engine rather than http://www.example.com/tiki-mobile.php. That is why it is called SEFURL, Search Engine Friendly URL, because it simplifies the complex URL.

Both file .htaccess and table tiki_sefurl_regex_out are connected using program file /tiki-sefurl.php and /lib/smarty_tiki/modifier.sefurl.php. So, if you want to add or update the SEFURL items, make sure that they are also programmed in those files. To see the examples, please read Tip 2: Modifying Tiki SEFURL for Page of Print Article and Tip 3: Modifying Tiki SEFURL for Page of Edit Submission or Submit an Article.

No comments:

Post a Comment