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 for catads and an SEO path. You will need to add this to the .htaccess file.
RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/admin/([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/catads/admin/$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/admin/([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/catads/admin/$2 [L,NC,QSA] RewriteRule ^ads/admin/([a-zA-Z0-9\&\%\_\-\=\?\.]+) modules/catads/admin/$1 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/comment_([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/catads/comment_$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/comment_([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/catads/comment_$2 [L,NC,QSA] RewriteRule ^ads/comment_([a-zA-Z0-9\&\%\_\-\=\?\.]+) modules/catads/comment_$1 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/images/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/catads/images/$3/$4 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/catads/images/$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/images/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/catads/images/$2/$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/catads/images/$2 [L,NC,QSA] RewriteRule ^ads/images/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/catads/images/$1/$2 [L,NC,QSA] RewriteRule ^ads/images/(.*) modules/catads/images/$1 [L,NC,QSA] RewriteRule ^adsimages/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/catads/images/$1/$2 [L,NC,QSA] RewriteRule ^adsimages/(.*) modules/catads/images/$1 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/catads/index.php [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/adslist.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/catads/adslist.php?$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/adsedit.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/catads/adsedit.php?$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/catads/index.php [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/adslist.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/catads/adslist.php?$2 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/adsedit.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/catads/adsedit.php?$2 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/addto/(.*) modules/catads/addto/$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/addto/(.*) modules/catads/addto/$2 [L,NC,QSA] RewriteRule ^ads/addto/(.*) modules/catads/addto/$1 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+),([0-9]+)$ modules/catads/adsitem.php?ads_cat=$1&ads_title=$2&ads_id=$3&cat_id=$4 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/$ modules/catads/adsitem.php?ads_cat=$1&ads_title=$2 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)$ modules/catads/adsitem.php?ads_cat=$1&ads_title=$2 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/catads/index.php [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/adslist.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/catads/adslist.php?$3 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/catads/index.php [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+),0$ modules/catads/adslist.php?ads_cat=$1&cat_id=$2&uid=0 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/0,([0-9]+)$ modules/catads/adslist.php?ads_cat=$1&cat_id=0&uid=$2 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)/$ modules/catads/adslist.php?ads_cat=$1 [L,NC,QSA] RewriteRule ^ads/([a-zA-Z0-9\ \%\_\-]+)$ modules/catads/adslist.php?ads_cat=$1 [L,NC,QSA] RewriteRule ^ads/adsedit.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/catads/adsedit.php?$1 [L,NC,QSA] RewriteRule ^ads/ modules/catads/index.php [L,NC,QSA] RewriteRule ^ads modules/catads/index.php [L,NC,QSA]
[edit]
Changes to the code
[edit]
index.php
inserted at line 26
if (strpos(' '.$_SERVER['REQUEST_URI'],'modules/')>0){
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: ".XOOPS_URL."/ads/");
}
[edit]
adsitem.php
Inserted at line 35
$ads_title = sef($ads_title,"_");
$ads_cat = sef($ads_cat,"_");
if ($ads_id==0&&$ads_cat!=''&&$ads_title!=''){
$sql = "SELECT a.ads_id FROM ".$xoopsDB->prefix('catads_ads')." a INNER JOIN ".$xoopsDB->prefix('catads_cat')." b on a.cat_id = b.cat_id WHERE a.ads_title LIKE '$ads_title' AND b.title LIKE '$ads_cat'";
$ret = $xoopsDB->query($sql);
$rt = $xoopsDB->fetchArray($ret);
$ads_id = $rt['ads_id'];
}
if ($ads_cat==''&&$ads_title==''){
$sql = "SELECT b.title, a.ads_title, a.cat_id FROM ".$xoopsDB->prefix('catads_ads')." a INNER JOIN ".$xoopsDB->prefix('catads_cat')." b on a.cat_id = b.cat_id WHERE a.ads_id=$ads_id";
$ret = $xoopsDB->query($sql);
$rt = $xoopsDB->fetchArray($ret);
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: ".XOOPS_URL."/ads/".sef($rt['title'])."/".sef($rt['ads_title'])."/".$ads_id.",".$rt['cat_id']);
}
[edit]
adslist.php
inserted at line 38
$ads_cat = sef($ads_cat,"_");
if ($ads_cat!=''&&$cat_id==0&&uid==0){
$sql = "SELECT b.title, b.cat_id FROM ".$xoopsDB->prefix('catads_cat')." b WHERE b.title LIKE '$ads_cat'";
$ret = $xoopsDB->query($sql);
$rt = $xoopsDB->fetchArray($ret);
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: ".getxoopsURL($rt['cat_id'])."/ads/".sef($rt['title'])."/".$rt['cat_id'].",0");
}
if ($ads_cat==''){
$sql = "SELECT b.title, b.cat_id FROM ".$xoopsDB->prefix('catads_cat')." b WHERE b.cat_id=$cat_id";
$ret = $xoopsDB->query($sql);
$rt = $xoopsDB->fetchArray($ret);
header( "HTTP/1.1 301 Moved Permanently" );
header( "Location: ".XOOPS_URL."/ads/".sef($rt['title'])."/".$cat_id.",0");
}

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






