User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
91 user(s) are online (9 user(s) are browsing XoopsWiki)

Members: 3
Guests: 88

optikool, pacho, status_tech, more...
[Main Page]

.htaccess & smartsection

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 edition of the .htaccess for smart section

RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/item.php$ modules/smartsection/item.php  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/item.php$ modules/smartsection/item.php [L,NC,QSA]
RewriteRule ^articles/item.php$ modules/smartsection/item.php  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/templates/(.*) modules/smartsection/templates/$3  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/smartsection/images/$3
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/smartsection/images/$2
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+) modules/smartsection/item.php?category=$1&item=$2&itemid=$3  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/ modules/smartsection/item.php?category=$1&item=$2  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+) modules/smartsection/item.php?category=$1&item=$2  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+)/ modules/smartsection/category.php?category=$1  [L,NC,QSA]
RewriteRule ^articles/([a-zA-Z0-9\ \%\_\-]+) modules/smartsection/category.php?category=$1  [L,NC,QSA]
RewriteRule ^articles/ modules/smartsection/index.php  [L,NC,QSA]
RewriteRule ^articles modules/smartsection/index.php  [L,NC,QSA]

Changes to the code

index.php

Insert at line 13

	if (strpos(' '.$_SERVER['REQUEST_URI'],"modules/")){
		header( "HTTP/1.1 301 Moved Permanently" ); 
		header( "Location: ".XOOPS_URL."/articles/");
	}

category.php

Insert at line 14

if (isset($_GET['category'])){
	$data = sef($_GET['category'],'_');
	$sql = "SELECT categoryid FROM ".$xoopsDB->prefix('smartsection_categories')." WHERE name LIKE '$data'";
	$ret = $xoopsDB->queryF($sql);
	$rt = $xoopsDB->fetchArray($ret);
	$categoryid = $rt['categoryid'];	
} else {
	$categoryid = isset($_GET['categoryid']) ? intval($_GET['categoryid']) : 0;
		$sql = "SELECT name FROM ".$xoopsDB->prefix('smartsection_categories')." WHERE categoryid = '$categoryid'";
		$ret = $xoopsDB->queryF($sql);
		$rt = $xoopsDB->fetchArray($ret);
		$name = $rt['name'];	
			
		header( "HTTP/1.1 301 Moved Permanently" ); 
		header( "Location: ".XOOPS_URL."/articles/".sef($name)."/");
}

item.php

insert at line 14

if (isset($_GET['category'])&&isset($_GET['item'])){
	$data = sef($_GET['category'],'_');
	$sql = "SELECT categoryid FROM ".$xoopsDB->prefix('smartsection_categories')." WHERE name LIKE '$data'";
	$ret = $xoopsDB->queryF($sql);
	$rt = $xoopsDB->fetchArray($ret);
	$categoryid = $rt['categoryid'];	
	$data = sef($_GET['item'],'_');
	$sql = "SELECT itemid FROM ".$xoopsDB->prefix('smartsection_items')." WHERE title LIKE '$data' and categoryid = '$categoryid'";
	$ret = $xoopsDB->queryF($sql);
	$rt = $xoopsDB->fetchArray($ret);
	$itemid = $rt['itemid'];
	$item_page_id = -1;
} else {
	$itemid = isset($_GET['itemid']) ? intval($_GET['itemid']) : 0;
	if (!empty($_GET['page'])){
		$item_page_id = isset($_GET['page']) ? intval($_GET['page']) : -1;
	} else {
		$sql = "SELECT title, categoryid FROM ".$xoopsDB->prefix('smartsection_items')." WHERE itemid = '$itemid'";
		$ret = $xoopsDB->queryF($sql);
		$rt = $xoopsDB->fetchArray($ret);
		$title = $rt['title'];
		$categoryid=	$rt['categoryid'];
	
		$sql = "SELECT name FROM ".$xoopsDB->prefix('smartsection_categories')." WHERE categoryid = '$categoryid'";
		$ret = $xoopsDB->queryF($sql);
		$rt = $xoopsDB->fetchArray($ret);
		$name = $rt['name'];	
			
		header( "HTTP/1.1 301 Moved Permanently" ); 
		header( "Location: ".XOOPS_URL."/articles/".sef($name)."/". sef($title)."/");
	}
}

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

This page has been accessed 2,929 times. This page was last modified 16:01, 1 June 2008. Content is available under XOOPS Project.


Developers for Hire
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

PHP 5

Powered by MySQL

Powered by Smarty

OSI certified

GPL

All content on this site is subject to the Creative Commons License
Top Tags
Theme (5) news (2) security (2) sport (1) Arabic (1) wiki (1) Christmas (1) jQuery (1) tag (1) module (1) SEO (1) comments (1)
Advertisement