Page 1 of 1

folder/892384 instead of folder/?892384 or folder/?id=892384

Posted: Mon Oct 14, 2002 8:53 pm
by phice
I'm making a small, custom-built forum for my website. I want each thread to have a real address, or atleast look like it is. I know how to do the ?892384 and ?id=892384 (who doesn't ;)). But, I want it to have a folder/892384, but not have to create that file each and every time a post is posted.

Any ideas? If you need any more information, please ask me.

Posted: Mon Oct 14, 2002 9:13 pm
by volka
i.e.

Code: Select all

<Location /board>
    SetHandler application/x-httpd-php
    Order allow,deny
    Allow from all
</Location>
any request on /php will be handled through php.
Having a php-script file forum in that directory a request for http://your.host/board/forum/892384 will result in

Code: Select all

$_SERVER&#1111;'SCRIPT_NAME'] == '/board/forum'
$_SERVER&#1111;'PATH_INFO'] == '/892384'
don't know wether this is clean or not - but it works ;)

Posted: Mon Oct 14, 2002 9:50 pm
by hob_goblin
Yes, you would be using htaccess simlar to php.net to tell your server

"if a real file is not found, and it's an integer, search for the # post"


look at the bottom of http://www.php.net/urlhowto.php

Posted: Mon Oct 14, 2002 9:55 pm
by mydimension
i do something similar to this on my forums. my requested uri's look like this:

Code: Select all

/forum/thread/######
then i use Apache's Rewrite Module to translate this to a page. here is what my conditions look like

Code: Select all

RewriteRule ^forum/thread/(&#1111;0-9]+)	/forum/thread.php?$1
so the above uri translates to this:

Code: Select all

/forum/thread.php?######
then in the first line of thread.php I have this

Code: Select all

$tid = $_SERVER&#1111;'argv']&#1111;0];
at that point i have my thread id and can use it as i wish. hope this helps and would be willing to help you more in getting your application to work.

Posted: Mon Jul 21, 2003 5:41 pm
by phice
erm, it's still not working (way delayed response. ;D)

I tried the above, mydimension, and still only getting a 404. Should the htaccess code be placed in a certain folder? I tried the /forum folder, and the default folder /.

Posted: Mon Jul 21, 2003 6:29 pm
by Gen-ik
Please correct me if I'm wrong but by the looks of things this can't be done without access to the Apache config file... which means if you don't run your own server or if your host won't allow you to edit the config file then there's no way of getting this to work?

8O

Posted: Mon Jul 21, 2003 6:50 pm
by phice
I'm just testing this on my home server for right now.