User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
104 user(s) are online (15 user(s) are browsing XoopsWiki)

Members: 3
Guests: 101

phoops, optikool, vamptrix, more...
[Main Page]

.htaccess & News

From XOOPS Project

Main Page | Recent changes | Edit this page | Page history | Switch to MediaWiki mode

Printable version | Disclaimers | Privacy policy

Contents

.htaccess & SEO

.htaccess file are used by apache to rewrite urls. This is very useful when doing an seo optimization. Some of you may have seen a couple of my sites where the modules are operating out side the /modules/ path this is done with a .htaccess file in the XOOPS_ROOT_PATH.

See .htaccess for more details

.htaccess

This is the modification for SEO paths for News

RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/comment_([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/news/comment_$3 [L,NC,QSA]
RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/news/images/$2  [L,NC,QSA]
RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/news/images/$2  [L,NC,QSA]
RewriteRule ^news/images/(.*) modules/news/images/$2  [L,NC,QSA]
RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+) modules/news/article.php?storycategory=$1&story_title=$2&storyid=$3  [L,NC,QSA]
RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/ modules/news/article.php?storycategory=$1&story_title=$2  [L,NC,QSA]
RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+),([0-9]+) modules/news/index.php?storycategory=$1&topic_id=$2&start=$3  [L,NC,QSA]
RewriteRule ^news/([a-zA-Z0-9\ \%\_\-]+)/ modules/news/index.php?storycategory=$1  [L,NC,QSA]
RewriteRule ^news/([0-9]+),([0-9]+) modules/news/index.php?topic_id=$1&start=$2  [L,NC,QSA]
RewriteRule ^news/ modules/news/index.php  [L,NC,QSA]
RewriteRule ^news modules/news/index.php  [L,NC,QSA]
RewriteRule ^news/article.php?storyid=([0-9]+) modules/news/article.php?storyid=$1 [L,NC,QSA]

Changes to the code

index.php

This is the change you have to make there is an IF statement at line 92, from line 91 to the end of this if statement this is the code you need.

$storytopic=0;
if(isset($_GET['storytopic'])||isset($_GET['storycategory'])) {
	if (isset($_GET['storycategory'])){
		$sql = "SELECT topic_id FROM ".$xoopsDB->prefix('topics')." WHERE topic_title Like '".$_GET['storycategory']."'";
		$ret = $xoopsDB->query($sql);
		$row = $xoopsDB->fetchArray($ret);
		if ($row['topic_id']!=0){
			$storytopic=$row['topic_id'];
		}
	} else {
		$storytopic=intval($_GET['storytopic']);

		$sql = "SELECT a.topic_title FROM ".$xoopsDB->prefix('topics')." a where a.topic_id = $storytopic";
		$ret = $xoopsDB->query($sql);
		$row = $xoopsDB->fetchArray($ret);
	
		header( "HTTP/1.1 301 Moved Permanently" ); 
		header( "Location: ".XOOPS_URL."/news/".sef($row['topic_title'])."/");

	}
} else {
	if(isset($_GET['topic_id'])) {
		$storytopic=intval($_GET['topic_id']);

		$sql = "SELECT a.topic_title FROM ".$xoopsDB->prefix('topics')." a where a.topic_id = $storytopic";
		$ret = $xoopsDB->query($sql);
		$row = $xoopsDB->fetchArray($ret);
	
		header( "HTTP/1.1 301 Moved Permanently" ); 
		header( "Location: ".XOOPS_URL."/news/".sef($row['topic_title'])."/");

	}
}

article.php

This is from line 128 to the end of the if statement below it, you will have to use this code.

$story_title = (isset($_GET['story_title'])) ? $_GET['story_title'] : '';
$storycategory = (isset($_GET['storycategory'])) ? $_GET['storycategory'] : '';

if (strlen($story_title)>0&&strlen($storycategory)>0){

	$sql = "SELECT topic_id FROM ".$xoopsDB->prefix('topics')." WHERE topic_title Like '".$_GET['storycategory']."'";
	$ret = $xoopsDB->query($sql);
	$row = $xoopsDB->fetchArray($ret);
	$sql = "SELECT storyid FROM ".$xoopsDB->prefix('stories')." WHERE title LIKE '$story_title' and topicid = ".$row['topic_id'];
	$ret = $xoopsDB->queryF($sql);
	$rt = $xoopsDB->fetchArray($ret);
	$storyid = $rt['storyid'];	
	
} else {
	$storyid = (isset($_GET['storyid'])) ? intval($_GET['storyid']) : 0;
	
	$sql = "SELECT a.topic_title, b.title FROM ".$xoopsDB->prefix('stories')." b INNER JOIN ".$xoopsDB->prefix('topics')." a on b.topicid = a.topic_id where b.storyid = $storyid";
	$ret = $xoopsDB->query($sql);
	$row = $xoopsDB->fetchArray($ret);
	
	header( "HTTP/1.1 301 Moved Permanently" ); 
	header( "Location: ".XOOPS_URL."/news/".sef($row['topic_title'])."/". sef($row['title'])."/");
}

Retrieved from "http://www.xoops.org/modules/mediawiki/index.php/.htaccess_%26_News"

This page has been accessed 2,021 times. This page was last modified 15:58, 1 June 2008. Content is available under XOOPS Project.


Developers for Hire
Local Support Sites
Make a donation
Please select an amount to donate


Do you want your username revealed with your donation?
Yes - List me as a Generous Donor
No - List my donation as from an Anonymous Donor


Powered by
XOOPS Code hosted on SourceForge

Powered by PHP



Powered by MySQL

Powered by Smarty

OSI certified

All content on this site is subject to the Creative Commons License
Advertisement