Contents |
[edit]
.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
[edit]
.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]
[edit]
Changes to the code
[edit]
index.php
Insert at line 13
if (strpos(' '.$_SERVER['REQUEST_URI'],"modules/")){
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: ".XOOPS_URL."/articles/");
}
[edit]
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)."/");
}
[edit]
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)."/");
}
}

![[Main Page]](/modules/mediawiki/images/mediawiki.png)






