User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
82 user(s) are online (8 user(s) are browsing XoopsWiki)

Members: 1
Guests: 81

crookedbranc, more...
[Main Page]

.htaccess & catads

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 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]

Changes to the code

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/");
	}

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']);
	

}

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");
}

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

This page has been accessed 2,023 times. This page was last modified 15:55, 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