mod_rewrite for dummies
aiwass |
|
---|---|
Well, it ain't working that's for sure. Everything except lists & pages. And to top things off http://www.megamind.se/index.php looks like it's missing a few things....
.htaccess RewriteEngine On RewriteBase / RewriteRule (datas|images|js|skins|plugins|system)/(.*)$ $1/$2 [L] RewriteCond %{REQUEST_URI} !=cdn-icons/megamind-icon.png RewriteRule ^admin$ admin.php [NC,NE,QSA,L] RewriteRule ^admin/([a-z]+)$ admin.php?m=$1 [NC,NE,QSA,L] RewriteRule ^login$ users.php?m=auth [NC,NE,QSA,L] RewriteRule ^logout/(.*)$ users.php?m=logout&x=$1 [NC,NE,QSA,L] RewriteRule ^users$ users.php [NC,NE,QSA,L] RewriteRule ^users/group:([0-9]+)$ users.php?gm=$1 [NC,NE,QSA,L] RewriteRule ^users/maingroup:([0-9]+)$ users.php?g=$1 [NC,NE,QSA,L] RewriteRule ^users/group:([0-9]+)/sort:([a-z]+)-(asc|desc)$ users.php?gm=$1&s=$2&w=$3 [NC,NE,QSA,L] RewriteRule ^users/maingroup:([0-9]+)/sort:([a-z]+)-(asc|desc)$ users.php?g=$1&s=$2&w=$3 [NC,NE,QSA,L] RewriteRule ^users/group:([0-9]+)/filter:(.*)$ users.php?gm=$1&f=$2 [NC,NE,QSA,L] RewriteRule ^users/maingroup:([0-9]+)/filter:(.*)$ users.php?g=$1&f=$2 [NC,NE,QSA,L] RewriteRule ^users/group:([0-9]+)/filter:(.*)/sort:([a-z]+)-(asc|desc)$ users.php?gm=$1&f=$2&s=$3&w=$4 [NC,NE,QSA,L] RewriteRule ^users/maingroup:([0-9]+)/filter:(.*)/sort:([a-z]+)-(asc|desc)$ users.php?g=$1&f=$2&s=$3&w=$4 [NC,NE,QSA,L] RewriteRule ^users/sort:([a-z]+)-(asc|desc)$ users.php?s=$1&w=$2 [NC,NE,QSA,L] RewriteRule ^users/filter:(.*)$ users.php?f=$1 [NC,NE,QSA,L] RewriteRule ^users/filter:(.*)/sort:([a-z]+)-(asc|desc)$ users.php?s=$1&w=$2 [NC,NE,QSA,L] RewriteRule ^user/(.*)$ users.php?m=details&u=$1 [NC,NE,QSA,L] RewriteRule ^user/edit/([0-9]+)$ users.php?m=edit&id=$1 [NC,NE,QSA,L] RewriteRule ^profile$ users.php?m=details [NC,NE,QSA,L] RewriteRule ^profile/edit$ users.php?m=profile [NC,NE,QSA,L] RewriteRule ^message/([0-9]+)$ message.php?msg=$1 [NC,NE,QSA,L] RewriteRule ^message/([0-9]+)/(.*)$ message.php?msg=$1&redirect=$2 [NC,NE,QSA,L] RewriteRule ^([0-9]+)$ page.php?id=$1 [NC,NE,QSA,L] RewriteRule ^([a-z0-9-/]+)/([0-9]+)$ page.php?id=$2 [NC,NE,QSA,L] RewriteRule ^([a-z0-9-]+)$ page.php?al=$1 [NC,NE,QSA,L] RewriteRule ^([a-z0-9-/]+)/([a-z0-9-]+)$ page.php?al=$2 [NC,NE,QSA,L] RewriteRule ^([a-z0-9-]+)/$ list.php?c=$1 [NC,NE,QSA,L] RewriteRule ^([a-z0-9-/]+)/([a-z0-9-]+)/$ list.php?c=$2 [NC,NE,QSA,L] urltrans.dat list c=* {list_url_structure()} page * {page_url_structure()} message msg=*&redirect=* message/{$msg}/{$redirect} message msg=* message/{$msg} admin m=* admin/{$m} admin * admin users m=details&id=*&u=* user/{$u}{!$id} users m=details&u=* user/{$u} users m=edit&id=* user/edit/{$id} users m=details profile users m=profile profile/edit users g=*&f=all&s=*&w=* users/maingroup:{$g}/sort:{$s}-{$w} users g=*&f=*&s=*&w=* users/maingroup:{$g}/filter:{$f}/sort:{$s}-{$w} users gm=*&f=all&s=*&w=* users/group:{$gm}/sort:{$s}-{$w} users gm=*&f=*&s=*&w=* users/group:{$gm}/filter:{$f}/sort:{$s}-{$w} users f=all&s=*&w=* users/sort:{$s}-{$w} users f=*&s=*&w=* users/filter:{$f}/sort:{$s}-{$w} users f=* users/filter:{$f} users gm=* users/group:{$gm} users g=* users/maingroup:{$g} users m=register&a=add register/add users m=register register users m=logout&x=* logout/{$x} users m=auth&a=check login/check users m=auth login users * users pm * pm rss * rss * * {$_area}.php functions.custom.php
defined('SED_CODE') or die('Wrong URL');
function list_url_structure(&$args, &$spec)
{
global $sed_cat;
$url = str_replace('.', '/', $sed_cat[$args['c']]['path']).'/';
unset($args['c']);
return $url;
}
function page_url_structure(&$args, &$spec)
{
global $sed_cat, $pag, $row, $rpagecat;
$page_cat = (!empty($sed_cat[$rpagecat]['path']) && empty($page_cat)) ? $sed_cat[$rpagecat]['path'] : $page_cat;
$page_cat = (!empty($sed_cat[$pag['page_cat']]['path']) && empty($page_cat)) ? $sed_cat[$pag['page_cat']]['path'] : $page_cat;
$page_cat = (!empty($sed_cat[$row['page_cat']]['path']) && empty($page_cat)) ? $sed_cat[$row['page_cat']]['path'] : $page_cat;
$url = str_replace('.', '/', $page_cat).'/';
if($args['id'])
{
$url .= $args['id'];
unset($args['id']);
}
else
{
$url .= urlencode($args['al']);
unset($args['al']);
}
return $url;
}
Added 3 days later: Update!The mod_rewrite now works, but with these rules and Rewrites, not the ones mentioned before in the thread:urltrans plug e=contactus contactus rss c=* {$_area}/{$c} list c=* {$_area}/{$c} page al=* {$c}/{$al} * * {$_area}.php htaccess RewriteEngine on RewriteBase / RewriteRule (datas|images|pics|cdn-icons|flyers|js|skins|plugins|system)/(.*)$ $1/$2 [L] RewriteCond %{REQUEST_URI} !=cdn-icons/megamind-icon.png RewriteRule ^rss/([^/&?#]+)(.*)$ rss.php?c=$1$2 [QSA,NC,NE,L] RewriteRule ^contactus(.*)$ plug.php?e=contactus$1 [QSA,NC,NE,L] RewriteRule ^list/([^/&?#]+)(.*)$ list.php?c=$1$2 [QSA,NC,NE,L] RewriteRule ^([^/&?#]+)/([^/&?#]+)(.*)$ page.php?c=$1&al=$2$3 [QSA,NC,NE,L] RewriteRule ^([^/&?#]+)/([^/&?#]+)(.*)$ page.php?c=$1&al=$2$3 [QSA,NC,NE,L] functions.custom <?php defined('SED_CODE') or die('Wrong URL'); function page_url_structure(&$args, &$spec) { global $sed_cat, $pag, $row, $rpagecat; $page_cat = (!empty($sed_cat[$rpagecat]['path']) && empty($page_cat)) ? $sed_cat[$rpagecat]['path'] : $page_cat; $page_cat = (!empty($sed_cat[$pag['page_cat']]['path']) && empty($page_cat)) ? $sed_cat[$pag['page_cat']]['path'] : $page_cat; $page_cat = (!empty($sed_cat[$row['page_cat']]['path']) && empty($page_cat)) ? $sed_cat[$row['page_cat']]['path'] : $page_cat; $url = str_replace('.', '/', $page_cat).'/'; if($args['id']) { $url .= $args['id']; unset($args['id']); } else { $url .= urlencode($args['al']); unset($args['al']); } return $url; } function list_url_structure(&$args, &$spec) { global $sed_cat; $url = str_replace('.', '/', $sed_cat[$args['c']]['path']).'/'; unset($args['c']); return $url; } ?> Take all that money that we spend on weapons and defences each year and instead spend it feeding and clothing and educating the poor of the world, which it would many times over, not one human being excluded, and we could explore space, together, both inner and outer, forever, in peace. - Bill Hicks
https://evlear.com |
|
Відредаговано: aiwass (22.01.2011 21:25, 14 років тому) |