Page 1 of 1
folder/485 not folder/?id=485
Posted: Sun Feb 16, 2003 4:46 pm
by phice
I'm looking for something that will allow the id=485 translate into a folder lookalike in the address bar.
In example, I've got a post #930. Normally, we'd use "/ReadPost.php?id=930", but I want "/930" instead. deviantArt uses this for their forum, and I'm wondering how they accomplished this.
Posted: Sun Feb 16, 2003 5:13 pm
by Stoker
use a script as the 404 Error handler (not found), defined in .htaccess if you are using a default Apache setup
Posted: Sun Feb 16, 2003 5:14 pm
by lazy_yogi
$id = $_POST['id'];
$id = "/".$id;
Posted: Sun Feb 16, 2003 5:28 pm
by phice
Stoker wrote:use a script as the 404 Error handler (not found), defined in .htaccess if you are using a default Apache setup
Then that would put tremendous strain on my Error logs.
Posted: Sun Feb 16, 2003 5:43 pm
by Stoker
I think that's how they do it, you can define away some log-options or perhaps some other apache-config settings that will call one file for any url..
There is no way to do this by scripting alone, as it is the webserver that reads the path and loads files accordingly..
Posted: Sun Feb 16, 2003 7:55 pm
by volka
for apache: if a handler is found everthing after is passed to this handler.
create a new directory (e.g.
test)and place a .htaccess and a file called
script in it.
content of .htaccess
content of
scriptCode: Select all
<html><body>
<table>
<?php
$n = array('QUERY_STRING', 'REQUEST_URI', 'SCRIPT_NAME', 'PATH_INFO', 'PATH_TRANSLATED', 'PHP_SELF');
foreach($n as $e)
echo '<tr><td>', $e, '</td><td>', $_SERVER[$e], '</td></tr>';
?>
</table>
</body></html>
now call this script e.g. by
http://a.ho.st/test/script/something123
Providers can disable this option, so it might not work.
Posted: Sun Feb 16, 2003 8:18 pm
by Stoker
that's a cool approach, didnt think about that one..
I am not sure why I didn't think about it at first; mod_rewrite - I believe that is the most common way for many scripts, just rewrite the url's matching a certain pattern/path to the script..
Posted: Sun Feb 16, 2003 11:17 pm
by phice
Well that didn't work.
Remember that I'm not in full control of the webserver. I've only got a shared-hosting service.
Posted: Mon Feb 17, 2003 8:41 am
by Stoker
Did you try mod_rewrite? most web hosts have that..
http://www.webmasterbase.com/article/910
something like
Code: Select all
RewriteEngine On
RewriteRule /myforum/(*) /index.php?thepath=$1
Posted: Mon Feb 17, 2003 2:02 pm
by EvilWalrus
better use 'RewriteRule /[0-9+] /index.php?id=$1' just to be safe... learn abotu regexp, it's your friend.
Posted: Mon Feb 17, 2003 2:08 pm
by Stoker
I am not that familiar with mod_rewrite but I assume that you need grouping to use $?
RewriteRule ^/([0-9]+) /index.php?id=$1
Posted: Mon Feb 17, 2003 11:19 pm
by phice
Would I place this inside the .htaccess? And, if so, which folder should I place it in? / or /boards/?
Posted: Tue Feb 18, 2003 7:39 am
by Stoker
in a .htaccess file yes, location depends on where you want the rule(s) to apply, you can move the file and/or you can change the matching pattern .. take a look at the link I posted above to get a better understanding of how mod_rewrite works..
Posted: Mon Feb 24, 2003 6:59 am
by superwormy
<FilesMatch "^scriptnamewhichlookslikeafolder$">
ForceType application/x-httpd-php
</FilesMatch>