Skip to main content Help Control Panel

YACS CMS : Open source !

Community «   Discussion forum «   Post your requirements here «  

Bernard - Shorter URLS :)

avatarRhodes, Nick -- on Aug. 23 2006, from West Yorkshire, UK
YACS team (UK)
http://www.ngr78.co.uk/articles/view.php/17/pages/2 rewritten to:

www.ngr78.co.uk/articles/view/17/pages/2 Give it a try

Requires this rewrite rule:

RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ([^0-9]+)/([0-9]+) $1.php/$2 [L]

This needs to be placed before RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]

eg:

# translate authentication data if PHP runs as CGI -- see agents/feed.php # RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ([^0-9]+)/([0-9]+) $1.php/$2 [L] RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization},L]

To test this we added the following line in global.php:

$path = str_replace('view', 'view.php', $path);

eg

if(isset($_SERVER['REQUEST_URI'])) { $path = str_replace('?'.$_SERVER['QUERY_STRING'], '', $_SERVER['REQUEST_URI']); $path = str_replace('view', 'view.php', $path); if($here = strpos($path, '.php/')) {

Obviously this needs coding correctly for getting the correct filename and generating the correct URLs

Cheers Nick (and a big help from Martyn)
Bernard
avatar
from nearby-an-airport
Associate, 7053 posts

on Aug. 26 2006


Your idea is good, because it makes things so simple. I will definitely give it a try within coming days. Thank you very much for this nice contribution.
Simplify3
avatar
from Naples, FL
51 posts

on Jul. 2 2007


Simplify3:

trouble! Rewrites suddenly not working after upgrade to 7.6!

I don't want to mess up my nicely-indexing site on Google - this could kill me - help!

Ken http://free.naplesplus.us/
Simplify3
avatar
from Naples, FL
51 posts

on Jul. 3 2007


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/

 
Share
Information channels
Recent files