Skip to main content Help Control Panel

Login   A+   A-

Development «   Development blog «  

url rewriting

Yes, YACS has been changed to accomodate for pretty URL rewriting!

The architecture is based on a standard .htaccess file, which implements standard rewriting rules adapted to yacs data model.

Provided rules support pages without or with nick names:
articles/123
articles/123-Foo_bar


Commands on items are also supported:
article-edit/123


In the main configuration panel, a third option has been introduced to enable URl rewriting by YACS, and this is closely linked to definitions put in .htaccess.

This is not limited to articles, and most items managed by a YACS server will become accessible through fake HTML references:
sections/456-My_taylor_is_rich
users/789-Nick


The system supports "dirty" nick names, that includes white spaces and UTF-8 characters, just in case...

1- GnapZ on June 19 2007

Works good but there is a bug while using parameters of pages in the url. It occurs when you want to clic on the next 20 pages of a big section.

Take a look at Yacs World in YacsInfo and try the link "21-40" at the bottom.

3- ThierryP on June 20 2007

All modifications they are made in the htaccess ?

Or another scripts they are modified ?

5- Simplify3 on Jul. 2 2007

Pretty rewrite seems to be broken in 7.6, at least for me.

Please let me know what to do!

I can no longer use;

http://free.naplesples.us/articles/view.php/1

which is what is indexed in google (and I worked hard to get it there0

and have to use;

http://free.naplesplus.us/articles/view.php?id=1

Please let me know what to do!!

ken

6- Simplify3 on Jul. 3 2007

Bernard: Update GLOBAL.PHP (if this is a universal fix and not just for PHP 4.4.0, which my server uses)

Problem: Pretty Links (view.php/section/37/news) stopped working for me in 7.6 upgrade.

Solution:

My fix for broken 7.6 (php 4.4.0) short links:

in GLOBAL.PHP:

Changed

$_SERVER['PATH_INFO']

to

$HTTP_SERVER_VARS['ORIG_PATH_INFO']

// analyze script args (e.g. 'articles/view.php/123/3', where '123' is the article id, and '3' is the page number)
if(isset($HTTP_SERVER_VARS['ORIG_PATH_INFO']) && strlen($HTTP_SERVER_VARS['ORIG_PATH_INFO'])) {

// split all args, if any, and decode each of them
$context['arguments'] = array();
$arguments = explode('/', substr($HTTP_SERVER_VARS['ORIG_PATH_INFO'], 1));
if(is_array($arguments)) {
foreach($arguments as $argument)
$context['arguments'][] = rawurldecode($argument);
}
}


In case it makes a difference, my .htaccess is:

# This file adds nice features to YACS
#
# Uncomment directives below depending of your needs.
# Do this one block at a time.
# Then load the main index page of your YACS server.
# If you experiment a 500 Internal Server Error then
# go back to the commented version.
#
# More support at http://www.yetanothercommunitysystem.com/
#

# ask Apache to redirect to pretty error pages
#
#ErrorDocument 401 /yacs/error.php?error=401
#ErrorDocument 403 /yacs/error.php?error=403
#ErrorDocument 404 /yacs/error.php?error=404

# disable directory browsing below this directory
#
#Options -Indexes

# set the default handler to index.php
#
DirectoryIndex index.php

# translate authentication data if PHP runs as CGI -- see agents/feed.php
#
#
# RewriteEngine on
# RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]
#

#download palm files
#
AddType application/octet-stream .prc .pdb
RewriteBase /
SetEnv TZ US/Eastern
AddDefaultCharset US-ASCII

ForceType application/x-httpd-php


Hope this works for someone else!

Ken, http://free.naplesplus.us/

8- Simplify3 on Jul. 3 2007

Note: I had to use the 7.4 VERSION of users/view.php in order to be able to edit/accept new users.

&whew& - upgrading is a tricky business!

9- Simplify3 on Jul. 4 2007, modified by Bernard - 

Bernard:
Submitted request:
$_REQUEST['utmz']=176852850.1183499610.6.7.utmccn=(organic)|utmcsr=google|utmctr=naplesplus|utmcmd=organic
$_REQUEST['
utma']=176852850.734508132.1183465870.1183499599.1183507800.7
$_REQUEST['PHPSESSID']=7390e6e74e72653f4207d6b3930e31fc
$_REQUEST['utmb']=176852850
$_REQUEST['
utmc']=176852850

Cookies sent by the browser:
$_COOKIE['utmz']=176852850.1183499610.6.7.utmccn=(organic)|utmcsr=google|utmctr=naplesplus|utmcmd=organic
$_COOKIE['
utma']=176852850.734508132.1183465870.1183499599.1183507800.7
$_COOKIE['PHPSESSID']=7390e6e74e72653f4207d6b3930e31fc
$_COOKIE['utmb']=176852850
$_COOKIE['
utmc']=176852850

Session data:
$_SESSION['watchdog']=1183508025
$_SESSION['browser_has_flash']=1
$_SESSION['surfer_id']=1
$_SESSION['surfer_name']=simplify3
$_SESSION['surfer_email_address']=
$_SESSION['surfer_capability']=A
$_SESSION['surfer_editor']=yacs
$_SESSION['surfer_gmt_offset']=0
$_SESSION['workstation_id']=76.101.3.170
$_SESSION['server_id']=/
$_SESSION['surfer_is_not_a_robot']=1
$_SESSION['test_hits']=1

Session variables are stored correctly if the counter increments on page reload: 2

Global YACS variables:
$context['host_name']=free.naplesplus.us
$context['url_to_home']=http://free.naplesplus.us
$context['url_to_root']=/
$context['script_url']=/control/test.php
$context['self_url']=http://free.naplesplus.us/control/test.php
$context['self_script']=/control/test.php
$context['charset']=utf-8

...

11- GnapZ on Jul. 4 2007

Bernard : Patch [article=3078]. Vérifier le bon emplacement du code inséré.

12- Bugmenot on Sep. 4 2007

Bernard:

Instead of using $HTTP_SERVER_VARS, I still recommend using $_SERVER, especially seeing that it's marked deprecated and will be removed in future versions of PHP.

$_SERVER['PATH_INFO'] = $_SERVER['ORIG_PATH_INFO'];

Rate this page
Posted by Bernard on June 12 2007, commented by Bernard on Sep. 9 2007, (popular)