Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 27th, 2005, 11:54 AM   #1
jubitzu
Newbie
 
Join Date: May 2005
Location: Colorful Colorado
Posts: 25
Rep Power: 0 jubitzu is on a distinguished road
RewriteRule

I am having trouble creating a rewrite rule to make my PHP app pretty.

/any/number/of/directories/article/mode/admin/action/delete

needs to be changed to

/any/number/of/directories/articles/index.php?mode=admin&action=delete

it should handle any number of arguments

/any/number/of/directories/article/mode/user/action/attachement/id/0193

needs to be changed to

/any/number/of/directories/articles/index.php?mode=user&action=attachment&id=0193

any ideas? is this possible?
jubitzu is offline   Reply With Quote
Old Sep 27th, 2005, 1:33 PM   #2
tempest
Programming Guru
 
tempest's Avatar
 
Join Date: Oct 2004
Posts: 1,041
Rep Power: 5 tempest is on a distinguished road
Send a message via ICQ to tempest Send a message via AIM to tempest Send a message via Yahoo to tempest
Of course it is...

404.php

[php]
<?php
function urlFormat($str, $sep="article/") {
$str = explode($sep, $str);
$str[1] = explode("/", $str[1]);
$tmp = "index.php?";

for($i=0;$i<count($str[1]);$i++) {
$tmp .= "{$str[1][$i]}=";
$i++;
$tmp .= "{$str[1][$i]}";
if($i != count($str[1])-1)
$tmp .= "&";
}

return "{$str[0]}{$sep}{$tmp}";
}

if(isset($_SERVER["REDIRECT_URL"]))
header("Location: " . urlFormat($_SERVER["REDIRECT_URL"]));
else die("404 Error Page...");
?>
[/php]

httpd.conf (in the directory tag of your root web folder)

ErrorDocument 404 /404.php

If this doesn't work, tell me, it's been a while since i've messed with Apache configs.
__________________

tempest is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:23 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC