Post Reply  Post Thread 
mod_rewrite for coppermine php/mysql database
freesouljah
Junior Member
**

Posts: 27
Group: Registered
Joined: Jun 2006
Status: Offline
Reputation: 0
Post: #1
Question mod_rewrite for coppermine php/mysql database

I saw the work you did for the MyBB SEO 1.0 Beta! mod and am very interested in the technique you used to change the url into one with the topic title...Surprised

I am a little tired right now, and in need of a good bath Worried so I really don't have time to read through all the code at the moment, but I am intrigued at how you did it and wonder if there were a way to use the same technique with the coppermine photo gallery. The mod_rewrite I am currently using for it is as follows:

Code:
/**
* Convert urls to search-engine friendly (SEF) urls
*/
function sef_urls_convert(&$html) {

    // Rewrite index.php?cat=[category]&page=[page] URLs to index-[category]-page-[page].html
    $html = preg_replace('/index\.php\?cat=([0-9]+)(\&|\&)page=([0-9]+)/i','index-$1-page-$3.html',$html);

    // Rewrite index.php?cat=[category] URLs to index-[category].html
    $html = preg_replace('/index\.php\?cat=([0-9]+)/i','index-$1.html',$html);
    
    // Rewrite thumbnails.php?album=[album]&cat=[category]&page=[category] URLs to thumbnails-[album]-[category]-page-[page].html
    $html = preg_replace('/thumbnails\.php\?album=([a-z0-9]+)(\&|\&)cat=([\-0-9]+)(\&|\&)page=([0-9]+)/i','thumbnails-$1-$3-page-$5.html',$html);
    
    // Rewrite thumbnails.php?album=[album]&cat=[category] URLs to thumbnails-[album]-[category].html
    $html = preg_replace('/thumbnails\.php\?album=([a-z0-9]+)(\&|\&)cat=([\-0-9]+)/i','thumbnails-$1-$3.html',$html);

#FIX BY DEVELAR
// Rewrite thumbnails.php?album=[album]&page=[category] URLs to thumbnails-[album]-page-[page].html
$html = preg_replace('/thumbnails\.php\?album=([a-z0-9]+)(\&|\&)page=([0-9]+)(\&|\&)sort=([a-z]+)/i','thumbnails-$1-page-$3-sort-$5.html',$html);



    // Rewrite thumbnails.php?album=[album]&page=[category] URLs to thumbnails-[album]-page-[page].html
    $html = preg_replace('/thumbnails\.php\?album=([a-z0-9]+)(\&|\&)page=([0-9]+)/i','thumbnails-$1-page-$3.html',$html);

// Rewrite thumbnails.php?album=[album]&page=[category]&sort=[sort] URLs to thumbnails-[album]-page-[page].html
    $html = preg_replace('/thumbnails\.php\?album=([a-z0-9]+)(\&|\&)page=([0-9]+)(\&|\&)sort=([a-z]+)/i','thumbnails-$1-page-$3-sort-$5.html',$html);




    // Rewrite thumbnails.php?album=search&search=[searchterm] URLs to thumbnails-search-[searchterm].html
    $html = preg_replace('/thumbnails\.php\?album=search(\&|\&)search=([^"]+)/i','thumbnails-search-$2.html',$html);
    
    // Rewrite thumbnails.php?album=[album] URLs to thumbnails-[album].html
    $html = preg_replace('/thumbnails\.php\?album=([a-z0-9]+)/i','thumbnails-$1.html',$html);


    // Rewrite displayimage.php?album=[album]&cat=[category]&pos=[position] URLs to displayimage-[album]-[category]-[position].html
    $html = preg_replace('/displayimage\.php\?album=([a-z0-9]+)(\&|\&)cat=([\-0-9]+)(\&|\&)pos=([\-0-9]+)/i','displayimage-$1-$3-$5.html',$html);

    // Rewrite displayimage.php?album=[album]&pos=[position] URLs to displayimage-[album]-[position].html
    $html = preg_replace('/displayimage\.php\?album=([a-z0-9]+)(\&|\&)pos=([\-0-9]+)/i','displayimage-$1-$3.html',$html);

    // Rewrite displayimage.php?pos=-[pid] URLs to displayimage-[pid].html
    $html = preg_replace('/displayimage\.php\?pos=-([0-9]+)/i','displayimage-$1.html',$html);


// adding filename
$picture_title = $CURRENT_PIC_DATA['title'] ? $CURRENT_PIC_DATA['title'] : strtr(preg_replace("/(.+)\..*?\Z/", "\\1", htmlspecialchars($CURRENT_PIC_DATA['filename'])), "_", " ");

// Rewrite displayimage.php?pid=[photo id]&fullsize=1','"  URLs to HQ/[photo id]
    $html = preg_replace('/displayimage\.php\?pid=([0-9]+)(\&|\&)fullsize=1/i','$1.html',$html);


    // Return modified HTML
    return $html;
}


and

Code:
#
# Rewrite index urls
#
RewriteRule index-([0-9]*)\.html index.php?cat=$1 [NC]

RewriteRule index-([0-9]*)-page-([0-9]*)\.html index.php?cat=$1&page=$2 [NC]

#
# Rewrite thumbnail urls
#
RewriteRule thumbnails-([a-z0-9]*)-([\-]?[0-9]*)\.html thumbnails.php?album=$1&cat=$2 [NC]

RewriteRule thumbnails-([a-z0-9]*)-page-([0-9]*)\.html thumbnails.php?album=$1&page=$2 [NC]

#FIX BY DEVELAR
RewriteRule thumbnails-([a-z0-9]+)-page-([0-9]+)-sort-([a-z]+)\.html thumbnails.php?album=$1&page=$2&sort=$3 [NC,L]


RewriteRule thumbnails-([a-z0-9]*)-([\-]?[0-9]*)-page-([0-9]*)\.html thumbnails.php?album=$1&cat=$2&page=$3 [NC]

RewriteRule thumbnails-([0-9]*)\.html thumbnails.php?album=$1 [NC]

RewriteRule thumbnails-search-(.*)\.html thumbnails.php?album=search&search=$1 [NC]



#
# Rewrite displayimage urls
#
RewriteRule displayimage-([a-z0-9]+)-([\-]?[0-9]+)-([\-]?[0-9]+)\.html displayimage.php?album=$1&cat=$2&pos=$3 [NC]

RewriteRule displayimage-([a-z0-9]+)-([\-]?[0-9]+)\.html displayimage.php?album=$1&pos=$2 [NC]

RewriteRule displayimage-([0-9]+)\.html displayimage.php?pos=-$1 [NC]

RewriteRule ([0-9]+)\.html displayimage.php?pid=$1&fullsize=1 [NC]


peaceCool


06-10-2006 05:09 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Pacifier
Administrator
*******

Posts: 222
Group: Administrators
Joined: May 2006
Status: Offline
Reputation: 1
Post: #2
RE: mod_rewrite for coppermine php/mysql database

I was myself looking into coppermine photo gallery's SEO, but it looks like due to lack of in-script cache, it won't be a very easy modification. Probably look back towards the end of the month, I may come up with something. ;)

06-10-2006 01:25 PM
Find all posts by this user Quote this message in a reply
freesouljah
Junior Member
**

Posts: 27
Group: Registered
Joined: Jun 2006
Status: Offline
Reputation: 0
Post: #3
RE: mod_rewrite for coppermine php/mysql database

cool...will do Big Grin


06-13-2006 10:51 PM
Visit this user's website Find all posts by this user Quote this message in a reply
CrazyKing
Junior Member
**

Posts: 1
Group: Registered
Joined: Oct 2006
Status: Offline
Reputation: 0
Post: #4
RE: mod_rewrite for coppermine php/mysql database

Where must i put 1st code and 2nd? Which files ?

10-20-2006 02:50 PM
Find all posts by this user Quote this message in a reply
Pacifier
Administrator
*******

Posts: 222
Group: Administrators
Joined: May 2006
Status: Offline
Reputation: 1
Post: #5
RE: mod_rewrite for coppermine php/mysql database

The code mentioned in the first post is the default "SEO plugin" that comes in Coppermine. I have done one SEO modification for coppermine myself, but releasing it is a far-cry from now.

10-20-2006 05:14 PM
Find all posts by this user Quote this message in a reply
Bas
Junior Member
**

Posts: 1
Group: Registered
Joined: Nov 2006
Status: Offline
Reputation: 0
Post: #6
RE: mod_rewrite for coppermine php/mysql database

Do you have any news about a good working seo frendly addon for Coppermine or do i understrand it wrong and you arent working on this at all?

11-25-2006 03:02 PM
Find all posts by this user Quote this message in a reply
Pacifier
Administrator
*******

Posts: 222
Group: Administrators
Joined: May 2006
Status: Offline
Reputation: 1
Post: #7
RE: mod_rewrite for coppermine php/mysql database

Well, I have written a SEO modification for Coppermine but I am not sure whether I will release it. It depends on the demand and so far it hasn't been of much.

11-25-2006 03:18 PM
Find all posts by this user Quote this message in a reply
Pepo
Junior Member
**

Posts: 9
Group: Registered
Joined: Jan 2007
Status: Offline
Reputation: 0
Post: #8
RE: mod_rewrite for coppermine php/mysql database

so thats good news..
like to see everything you made mate Smile


تطوير منتديات ماى بى بى - اشهار المواقع - cheap web host
04-22-2008 11:19 AM
Find all posts by this user Quote this message in a reply
asics
Junior Member
**

Posts: 19
Group: Registered
Joined: Oct 2010
Status: Offline
Reputation: 0
Post: #9
RE: mod_rewrite for coppermine php/mysql database
11-01-2010 12:46 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites

Forum Jump: