Jump to content

PunBB forum URL scheme


coder500

Recommended Posts

Hi

 

I have installed punbb forum on my local machine. Set the URL scheme to File based Fancy.

 

Now the URL appears as http://localhost/pforum3/topic2-how-rewrite-is-working.html

 

pforum3 is the directory in which I installed the forum.

 

I want to change the URL to http://localhost/how-rewrite-is-working.html.

 

Is this possible? I am attaching 2 files, which seems to be doing this URL rewrite.

 

Any help will be very much appreciated.

 

forum_urls.php

<?php
/**
* SEF URLs that use a file-like layout and include topic name and forum name
* where applicable.
*
* @copyright (C) 2008-2009 PunBB, partially based on code (C) 2008-2009 FluxBB.org
* @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
* @package PunBB
*/


// Make sure no one attempts to run this script "directly"
if (!defined('FORUM'))
exit;

// These are the "fancy" file based SEF URLs
$forum_url = array(
'insertion_find'				=>  '.html',
'insertion_replace'				=>  '-$1.html',
'change_email'					=>	'change-email$1.html',
'change_email_key'				=>	'change-email$1-$2.html',
'change_password'				=>	'change-password$1.html',
'change_password_key'			=>	'change-password$1-$2.html',
'delete_user'					=>	'delete-user$1.html',
'delete'						=>	'delete$1.html',
'delete_avatar'					=>	'delete-avatar$1-$2.html',
'edit'							=>	'edit$1.html',
'email'							=>	'email$1.html',
'forum'							=>	'forum$1-$2.html',
'forum_rss'						=>	'feed-rss-forum$1.xml',
'forum_atom'					=>	'feed-atom-forum$1.xml',
'help'							=>	'help-$1.html',
'index'							=>	'',
'index_rss'						=>	'feed-rss.xml',
'index_atom'					=>	'feed-atom.xml',
'login'							=>	'login.html',
'logout'						=>	'logout$1-$2.html',
'mark_read'						=>	'mark-read-$1.html',
'mark_forum_read'				=>	'mark-forum$1-read-$2.html',
'new_topic'						=>	'new-topic$1.html',
'new_reply'						=>	'new-reply$1.html',
'post'							=>	'post$1.html#p$1',
'profile_about'					=>	'user$1-about.html',
'profile_identity'				=>	'user$1-identity.html',
'profile_settings'				=>	'user$1-settings.html',
'profile_avatar'				=>	'user$1-avatar.html',
'profile_signature'				=>	'user$1-signature.html',
'profile_admin'					=>	'user$1-admin.html',
'quote'							=>	'new-reply$1quote$2.html',
'register'						=>	'register.html',
'report'						=>	'report$1.html',
'request_password'				=>	'request-password.html',
'rules'							=>	'rules.html',
'search'						=>	'search.html',
'search_resultft'				=>	'search-k$1-$4-a$3-$5-$6-$2-$7.html',
'search_results'				=>	'search$1.html',
'search_new'					=>	'search-new.html',
'search_new_results'			=>	'search-new-$1.html',
'search_recent'					=>	'search-recent.html',
'search_recent_results'			=>	'search-recent-$1.html',
'search_unanswered'				=>	'search-unanswered.html',
'search_subscriptions'			=>	'search-subscriptions$1.html',
'search_user_posts'				=>	'search-posts-user$1.html',
'search_user_topics'			=>	'search-topics-user$1.html',
'subscribe'						=>	'subscribe$1-$2.html',
'topic'							=>	'topic$1-$2.html',
'topic_rss'						=>	'feed-rss-topic$1.xml',
'topic_atom'					=>	'feed-atom-topic$1.xml',
'topic_new_posts'				=>	'topic$1-$2-new-posts.html',
'topic_last_post'				=>	'topic$1last-post.html',
'unsubscribe'					=>	'unsubscribe$1-$2.html',
'user'							=>	'user$1.html',
'users'							=>	'users.html',
'users_browse'					=>	'users/$4/$1$2-$3.html',
'page'							=>	'p$1',
'moderate_forum'				=>	'moderate$1.html',
'get_host'						=>	'get_host$1.html',
'move'							=>	'move_topics$1-$2.html',
'open'							=>	'open$1-$2-$3.html',
'close'							=>	'close$1-$2-$3.html',
'stick'							=>	'stick$1-$2-$3.html',
'unstick'						=>	'unstick$1-$2-$3.html',
'moderate_topic'				=>	'moderate$1-$2.html',
'admin_index'					=>	'admin/index.php',
'admin_bans'					=>	'admin/bans.php',
'admin_categories'				=>	'admin/categories.php',
'admin_censoring'				=>	'admin/censoring.php',
'admin_extensions_manage'		=>	'admin/extensions.php?section=manage',
'admin_extensions_hotfixes'		=>	'admin/extensions.php?section=hotfixes',
'admin_forums'					=>	'admin/forums.php',
'admin_groups'					=>	'admin/groups.php',
'admin_loader'					=>	'admin/loader.php',
'admin_reindex'					=>	'admin/reindex.php',
'admin_settings_setup'			=>	'admin/settings.php?section=setup',
'admin_settings_features'		=>	'admin/settings.php?section=features',
'admin_settings_content'		=>	'admin/settings.php?section=content',
'admin_settings_email'			=>	'admin/settings.php?section=email',
'admin_settings_announcements'	=>	'admin/settings.php?section=announcements',
'admin_settings_registration'	=>	'admin/settings.php?section=registration',
'admin_settings_communications'	=>	'admin/settings.php?section=communications',
'admin_settings_maintenance'	=>	'admin/settings.php?section=maintenance',
'admin_prune'					=>	'admin/prune.php',
'admin_ranks'					=>	'admin/ranks.php',
'admin_reports'					=>	'admin/reports.php',
'admin_users'					=>	'admin/users.php'
);

rewrite_rules.php

<?php
/**
* Loads the regular expressions used to match SEF URL requests to their proper URLs.
*
* @copyright (C) 2008-2009 PunBB, partially based on code (C) 2008-2009 FluxBB.org
* @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
* @package PunBB
*/


$forum_rewrite_rules = array(
'/^topic[\/_-]?([0-9]+).*(new|last)[\/_-]?(posts?)(\.html?|\/)?$/i'														=>	'viewtopic.php?id=$1&action=$2',
'/^post[\/_-]?([0-9]+)(\.html?|\/)?$/i'																					=>	'viewtopic.php?pid=$1',
'/^(forum|topic)[\/_-]?([0-9]+).*[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'											=>	'view$1.php?id=$2&p=$4',
'/^feed[\/_-]?(rss|atom)[\/_-]?(f|t)(orum|opic)[\/_-]?([0-9]+)[\/_-]?(\.xml?|\/)?$/i'									=>	'extern.php?action=feed&$2id=$4&type=$1',
'/^(forum|topic)[\/_-]?([0-9]+).*(\.html?|\/)?$/i'																		=>	'view$1.php?id=$2',
'/^new[\/_-]?reply[\/_-]?([0-9]+)(\.html?|\/)?$/i'																		=>	'post.php?tid=$1',
'/^new[\/_-]?reply[\/_-]?([0-9]+)[\/_-]?quote[\/_-]?([0-9]+)(\.html?|\/)?$/i'											=>	'post.php?tid=$1&qid=$2',
'/^new[\/_-]?topic[\/_-]?([0-9]+)(\.html?|\/)?$/i'																		=>	'post.php?fid=$1',
'/^(delete|edit)[\/_-]?([0-9]+)(\.html?|\/)?$/i'																		=>	'$1.php?id=$2',
'/^(login|search|register)(\.html?|\/)?$/i'																				=>	'$1.php',
'/^logout[\/_-]?([0-9]+)[\/_-]([a-z0-9]+)(\.html?|\/)?$/i'																=>	'login.php?action=out&id=$1&csrf_token=$2',
'/^request[\/_-]?password(\.html?|\/)?$/i'																				=>	'login.php?action=forget',
'/^user[\/_-]?([0-9]+)(\.html?|\/)?$/i'																					=>	'profile.php?id=$1',
'/^user[\/_-]?([0-9]+)[\/_-]?([a-z]+)(\.html?|\/)?$/i'																	=>	'profile.php?section=$2&id=$1',
'/^(delete)[\/_-]?(avatar|user)?[\/_-]?([0-9]+)[\/_-]?([a-z0-9]+)?(\.html?|\/)?$/i'										=>	'profile.php?action=$1_$2&id=$3&csrf_token=$4',
'/^change[\/_-]?(email|pass)(word)?[\/_-]?([0-9]+)[\/_-]([a-zA-Z0-9]+)(\.html?|\/)?$/i'									=>	'profile.php?action=change_$1&id=$3&key=$4',
'/^change[\/_-]?(email|pass)(word)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'														=>	'profile.php?action=change_$1&id=$3',
'/^search[\/_-]?(new)[\/_-]([0-9-]+)(\.html?|\/)?$/i'																	=>	'search.php?action=show_new&forum=$2',
'/^search[\/_-]?(new)[\/_-]([0-9-]+)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'										=>	'search.php?action=show_new&forum=$2&p=$4',
'/^search[\/_-]?(recent)[\/_-]([0-9]+)(\.html?|\/)?$/i'																	=>	'search.php?action=show_recent&value=$2',
'/^search[\/_-]?(recent)[\/_-]([0-9]+)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'										=>	'search.php?action=show_recent&value=$2&p=$4',
'/^search[\/_-]?(new|recent|unanswered)(\.html?|\/)?$/i'																=>	'search.php?action=show_$1',
'/^search[\/_-]?(new|recent|unanswered)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'									=>	'search.php?action=show_$1&p=$3',
'/^search[\/_-]?subscriptions[\/_-]?([0-9]+)(\.html?|\/)?$/i'															=>	'search.php?action=show_subscriptions&user_id=$1',
'/^search[\/_-]?subscriptions[\/_-]?([0-9]+)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'								=>	'search.php?action=show_subscriptions&user_id=$1&p=$3',
'/^search[\/_-]?([0-9]+)(\.html?|\/)?$/i'																				=>	'search.php?search_id=$1',
'/^search[\/_-]?([0-9]+)[\/_-]?p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'													=>	'search.php?search_id=$1&p=$3',
'/^search[\/_-]?(posts|topics)[\/_-]?user[\/_-]?([0-9]+)(\.html?|\/)?$/i'												=>	'search.php?action=show_user_$1&user_id=$2',
'/^search[\/_-]?(posts|topics)[\/_-]?user[\/_-]?([0-9]+)[\/_-]?p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'					=>	'search.php?action=show_user_$1&user_id=$2&p=$4',
'/^search\/k(.*)\/([0-9-]+)\/a(.*)\/(message|subject|all)\/([0-9]+)\/(ASC|DESC)\/(posts|topics)\/?$/i'					=>	'search.php?action=search&keywords=$1&author=$3&forum=$2&search_in=$4&sort_by=$5&sort_dir=$6&show_as=$7',
'/^search\/k(.*)\/([0-9-]+)\/a(.*)\/(message|subject|all)\/([0-9]+)\/(ASC|DESC)\/(posts|topics)\/page\/([0-9]+)\/?$/i'	=>	'search.php?action=search&keywords=$1&author=$3&forum=$2&search_in=$4&sort_by=$5&sort_dir=$6&show_as=$7&p=$8',
'/^search-k(.*)-([0-9-]+)-a(.*)-(message|subject|all)-([0-9]+)-(ASC|DESC)-(posts|topics).html?$/i'						=>	'search.php?action=search&keywords=$1&author=$3&forum=$2&search_in=$4&sort_by=$5&sort_dir=$6&show_as=$7',
'/^search-k(.*)-(message|subject|all)-a(.*)-([0-9]+)-(ASC|DESC)-([0-9-]+)-(posts|topics)-p([0-9]+).html?$/i'			=>	'search.php?action=search&keywords=$1&author=$3&forum=$6&search_in=$2&sort_by=$4&sort_dir=$5&show_as=$7&p=$8',
'/^users(\.html?|\/)?$/i'																								=>	'userlist.php',
'/^users\/(.*)\/([0-9-]+)\/?([a-z_]+)[\/_-]([a-zA-Z]+)[\/_-]p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'						=>	'userlist.php?username=$1&show_group=$2&sort_by=$3&sort_dir=$4&p=$6',
'/^users\/(.*)\/([0-9-]+)\/?([a-z_]+)[\/_-]([a-zA-Z]+)(\.html?|\/)?$/i'													=>	'userlist.php?username=$1&show_group=$2&sort_by=$3&sort_dir=$4',
'/^(email|report|subscribe|unsubscribe)[\/_-]?([0-9]+)[\/_-]?([a-z0-9]+)?(\.html?|\/)?$/i'								=>	'misc.php?$1=$2&csrf_token=$3',
'/^(mark|rules)[\/_-]?(read)?[\/_-]?([a-z0-9]+)?(\.html?|\/)?$/i'														=>	'misc.php?action=$1$2&csrf_token=$3',
'/^mark[\/_-](forum)[\/_-]?([0-9]+)[\/_-](read)[\/_-]([a-z0-9]+)(\.html?|\/)?$/i'										=>	'misc.php?action=markforumread&fid=$2&csrf_token=$4',
'/^help[\/_-]([a-z]+)(\.html?|\/)?$/i'																					=>	'help.php?section=$1',
'/^moderate[\/_-]?([0-9]+)(\.html?|\/)?$/i'																				=>	'moderate.php?fid=$1',
'/^move_topics[\/_-]?([0-9]+)[\/_-]([0-9]+)(\.html?|\/)?$/i'															=>	'moderate.php?fid=$1&move_topics=$2',
'/^(open|close|stick|unstick)[\/_-]?([0-9]+)[\/_-]([0-9]+)[\/_-]([a-z0-9]+)(\.html?|\/)?$/i'							=>	'moderate.php?fid=$2&$1=$3&csrf_token=$4',
'/^moderate[\/_-]?([0-9]+)[\/_-]?p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'												=>	'moderate.php?fid=$1&p=$3',
'/^moderate[\/_-]?([0-9]+)[\/_-]([0-9]+)(\.html?|\/)?$/i'																=>	'moderate.php?fid=$1&tid=$2',
'/^moderate[\/_-]?([0-9]+)[\/_-]([0-9]+)[\/_-]?p(age)?[\/_-]?([0-9]+)(\.html?|\/)?$/i'									=>	'moderate.php?fid=$1&tid=$2&p=$4',
'/^get_host[\/_-]?([0-9]+|[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})(\.html?|\/)?$/i'								=>	'moderate.php?get_host=$1',
'/^feed[\/_-]?(rss|atom)(\.xml?|\/)?$/i'																				=>	'extern.php?action=feed&type=$1'
);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.