Forum Moderators: phranque
I have searched the board and read the Apache tutorial, however I can not localize an existing solution to my question.
In short there's a forum in directory mydomain.com/forum/
This directory will contain url's like mydomain.com/forum/topic1
My hope is to be able to rewrite all requests for files such that the above example would become mydomain.com/topic1
Any help is much appreciated, as well as thoughts on possible problems (SE-related and other).
Sincere thanks,
Joe Belmaati
Copenhagen Denmark
First, edit the forum script so that it produces URLs (on-page links) in the form: mydomain.com/topic1
Then, create a RewriteRule to rewrite requests for mydomain.com/topic<0-99999> into requests for mydomain.com/forum/topic<0-99999>
In your RewriteRule, you will create and use a back-reference to "copy" the topic number from the requested URL into the actual filepath.
You must take care that there is no file in your root directory named "topic<any_number>", otherwise this will cause problems.
Note that mod_rewrite does not "move" anything; It simply changes the relationship between requested URLs and the corresponding request filepaths in the filesystem. In this case, all it does is to insert "/forum" into the requested URL and pass that new URL as a filename to the Apache content-handler, which serves that file's content (this requested file is your forum script in this case).
Jim
How do I make all requests to
/forum
invisibly rewrite to
/
instead...?
BTW I have found lots of pages describing how to rewrite requests from / to /dir, but none that describe the reverse process. Simply reversing the statements doesn't seem to work...
The references in our charter [webmasterworld.com] are a good place to start.
RewriteRule ^forum/(.*) /$1 [L]