User Login    
 + Register
  • Main navigation
Login
Username:

Password:

Remember me



Lost Password?

Register now!
Who's Online
105 user(s) are online (10 user(s) are browsing XoopsWiki)

Members: 2
Guests: 103

kontrolfreek, abinsblaue, more...
[Main Page]

.htaccess & myAlbum-p

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

RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/admin/([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/myalbum/admin/$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/admin/([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/myalbum/admin/$2 [L,NC,QSA]
RewriteRule ^album/admin/([a-zA-Z0-9\&\%\_\-\=\?\.]+) modules/myalbum/admin/$1 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/comment_([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/myalbum/comment_$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/comment_([a-zA-Z0-9\&\%\?\_\.\-\=]+) modules/myalbum/comment_$2 [L,NC,QSA]
RewriteRule ^album/comment_([a-zA-Z0-9\&\%\_\-\=\?\.]+) modules/myalbum/comment_$1 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/images/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/myalbum/images/$3/$4 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/myalbum/images/$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/images/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/myalbum/images/$2/$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/images/(.*) modules/myalbum/images/$2 [L,NC,QSA]
RewriteRule ^album/images/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/myalbum/images/$1/$2 [L,NC,QSA]
RewriteRule ^album/images/(.*) modules/myalbum/images/$1 [L,NC,QSA]
RewriteRule ^albumimages/([a-zA-Z0-9\ \%\_\-]+)/(.*) modules/myalbum/images/$1/$2 [L,NC,QSA]
RewriteRule ^albumimages/(.*) modules/myalbum/images/$1 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/submit.php modules/myalbum/submit.php [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/submit.php modules/myalbum/submit.php [L,NC,QSA]
RewriteRule ^album/submit.php modules/myalbum/submit.php [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/myalbum/index.php [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/viewcat.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/viewcat.php?$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/editphoto.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/editphoto.php?$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/ratephoto.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/ratephoto.php?$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/myalbum/index.php [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/viewcat.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/viewcat.php?$2 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/editphoto.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/editphoto.php?$2 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/ratephoto.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/ratephoto.php?$2 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/addto/(.*) modules/myalbum/addto/$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/addto/(.*) modules/myalbum/addto/$2 [L,NC,QSA]
RewriteRule ^album/addto/(.*) modules/myalbum/addto/$1 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+),([0-9]+)$ modules/myalbum/photo.php?ads_cat=$1&ads_title=$2&lid=$3&cid=$4 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/$ modules/myalbum/photo.php?ads_cat=$1&ads_title=$2 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)$ modules/myalbum/photo.php?ads_cat=$1&ads_title=$2 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/myalbum/index.php [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/viewcat.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/viewcat.php?$3 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([a-zA-Z0-9\ \%\_\-]+)/index.php modules/myalbum/index.php [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/([0-9]+),([0-9]+),([0-9]+),([0-9]+),([0-9]+),([a-zA-Z0-9]+)$ modules/myalbum/viewcat.php?ads_cat=$1&cid=$2&uid=$3&num=$4&pos=$5&view=$6&orderby=$7 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)/$ modules/myalbum/viewcat.php?ads_cat=$1 [L,NC,QSA]
RewriteRule ^album/([a-zA-Z0-9\ \%\_\-]+)$ modules/myalbum/viewcat.php?ads_cat=$1 [L,NC,QSA]
RewriteRule ^album/([0-9]+),([0-9]+) modules/myalbum/index.php?num=$1&pos=$2 [L,NC,QSA]
RewriteRule ^album/editphoto.php?([a-zA-Z0-9\=\&\_\-]+)$ modules/myalbum/editphoto.php?$1 [L,NC,QSA]
RewriteRule ^album/ modules/myalbum/index.php [L,NC,QSA]
RewriteRule ^album modules/myalbum/index.php [L,NC,QSA]

Change to the code

index.php

Insert at line 8

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

photo.php

insert after include('../../mainfile.php');

	$ads_title = empty( $_GET['ads_title'] ) ? '' : ( sef($_GET['ads_title'],'_') ) ;
	$ads_cat = empty( $_GET['ads_cat'] ) ? '' : ( sef($_GET['ads_cat'],'_') ) ;
	
	if ($lid==0&&$ads_cat!=''&&$ads_title!=''){
		$sql = "SELECT a.lid, a.cid FROM ".$xoopsDB->prefix('myalbum_photos')." a INNER JOIN ".$xoopsDB->prefix('myalbum_cat')." b on a.cid = b.cid WHERE a.title LIKE '$ads_title' AND b.title LIKE '$ads_cat'";
		$ret = $xoopsDB->query($sql);
		$rt = $xoopsDB->fetchArray($ret);
		$lid = $rt['lid'];
		$cid = $rt['cid'];
	}
	
	
	if ($ads_cat==''&&$ads_title==''){
		$sql = "SELECT a.title, b.title as cat_title, a.lid, a.cid FROM ".$xoopsDB->prefix('myalbum_photos')." a INNER JOIN ".$xoopsDB->prefix('myalbum_cat')." b on a.cid = b.cid WHERE a.lid=$lid";
		$ret = $xoopsDB->query($sql);
		$rt = $xoopsDB->fetchArray($ret);
		header( "HTTP/1.1 301 Moved albumly" ); 
		header( "Location: ".XOOPS_URL."/album/".sef($rt['cat_title'])."/".sef($rt['title'])."/".$rt['lid'].",".$rt['cid']);
			
	}

		
	$query_rsTitle = "SELECT  ".$xoopsDB->prefix('myalbum_photos').".comments ,".$xoopsDB->prefix('myalbum_photos').".title as phtTitle,  ".$xoopsDB->prefix('myalbum_cat').".title as CatTitle FROM ".$xoopsDB->prefix('myalbum_photos')." inner join ".$xoopsDB->prefix('myalbum_cat')." on ".$xoopsDB->prefix('myalbum_cat').".cid = ".$xoopsDB->prefix('myalbum_photos').".cid where ".$xoopsDB->prefix('myalbum_photos').".lid = $lid";
	$rsTitle = $xoopsDB->query($query_rsTitle);
	$row_rsTitle = $xoopsDB->fetchArray($rsTitle);
	$totalRows_rsTitle = mysql_num_rows($rsTitle);
	
	if ($totalRows_rsTitle==0){
		header( "HTTP/1.1 301 Moved albumly" ); 
		header( "Location: http://".$_SERVER['HTTP_HOST']."/modules/myalbum/");
		echo "301 - Moved or Deleted albumly - redirecting to <a href='http://".$_SERVER['HTTP_HOST']."/modules/myalbum/'>http://".$_SERVER['HTTP_HOST']."/modules/myalbum/</a>";
		 
		exit();
	}

viewcat.php

Insert from line 10:

$ads_cat = empty( $_GET['ads_cat'] ) ? '' : ( sef($_GET['ads_cat'],'_') ) ;


	if ($ads_cat!=''&&$cid==0){
		$sql = "SELECT b.title, b.cid FROM ".$xoopsDB->prefix('myalbum_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: ".XOOPS_URL."/album/".sef($rt['title'])."/".$rt['cid'].",$uid,$num,$pos,$view,$orderby");
	}
	
	if ($ads_cat==''){
		$sql = "SELECT b.title, b.cid FROM ".$xoopsDB->prefix('myalbum_cat')." b WHERE b.cid=$cid";
		$ret = $xoopsDB->query($sql);
		$rt = $xoopsDB->fetchArray($ret);
		header( "HTTP/1.1 301 Moved Permanently" ); 
		header( "Location: ".XOOPS_URL."/album/".sef($rt['title'])."/".$cid.",$uid,$num,$pos,$view,$orderby");
	}

	if ($cid!=0){
	
		$query_rsTitle = "SELECT count(*) as rec_count FROM ` ".$xoopsDB->prefix('myalbum_photos')."` WHERE ` ".$xoopsDB->prefix('myalbum_photos')."`.cid = $cid";
		$rsTitle = $xoopsDB->query($query_rsTitle);
		$row_rsTitle = $xoopsDB->fetchArray($rsTitle);
		$totalRows_rsTitle = mysql_num_rows($rsTitle);
	
		if ($row_rsTitle['rec_count']==0) {
			header( "HTTP/1.1 302 Moved Temporarily" ); 
			header( "Location: ".XOOPS_URL."/modules/myalbum/");	
		}
	}
	

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

This page has been accessed 2,488 times. This page was last modified 16:02, 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