This is a discussion on apache configuration within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi all, I am pretty much a PHP developer and I have a new idea for my website. To implement ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all,
I am pretty much a PHP developer and I have a new idea for my website. To implement the new idea I guess I need some basic configuration on apache. I have my index.php and everything runs depend on that file. Now I want to manage any other requests on root directory other than the index.php is handled. For example: for now, www.mydomain.com/index.php?foo=bar etc. works as expected but I want any other requests like www.mydomain.com/bla, www.mydomain.com/qwerty, www.mydomain.com/awsome, www.mydomain.com/danger are hadled somehow. I suppose there should be a solution like handling any requests "which is not handled as usual" for example if I have some php file in some directory like www.mydomain.com/somedir/somefile.php it should be run as expected but lets say if I don't have "thisfiledoesntexist" in my directory structure like www.mydomain.com/thisfiledoesntexist, this request should be handled by lets say another php script called www.mydomain.com/unhandled.php can you suggest anything? Cheers Baris |
|
|||
|
On May 5, 4:46*am, "cel...@gmail.com" <cel...@gmail.com> wrote:
> Hi all, > > I am pretty much a PHP developer and I have a new idea for my website. > To implement the new idea I guess I need some basic configuration on > apache. > I have my index.php and everything runs depend on that file. Now I > want to manage any other requests on root directory other than the > index.php is handled. > For example: > for now,www.mydomain.com/index.php?foo=baretc. works as expected > but I want any other requests likewww.mydomain.com/bla,http://www.mydomain.com/qwerty,www.m....com/dangerare hadled somehow. > I suppose there should be a solution like handling any requests "which > is not handled as usual" > for example if I have some php file in some directory likewww.mydomain.com/somedir/somefile.phpit should be run as expected but > lets say if I don't have "thisfiledoesntexist" in my directory > structure likewww.mydomain.com/thisfiledoesntexist, this request > should be handled by lets say another php script calledwww.mydomain.com/unhandled.php > > can you suggest anything? > > Cheers > Baris i'd recommend against having all files in your root htdocs directory run off mod_rewrite since you said you wanted some files in subdirectories to load normally without rewriting rules. if you want to go this route though, you should probably send all requests through a single php file: 1) enable mod_rewrite on / in httpd.conf, e.g.: <Directory "/"> RewriteEngine on RewriteBase / RewriteRule ^(.+)$ /handler.php?r=$1 </Directory> 2) create a php file that handles all requests, e.g.: <?php switch ( $_GET['r'] ): case "something": require_once('assets/something.php'); break; case "something_else": require_once('assets/something_else.php'); break; default: if ( file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . $_GET['r']) ) { require_once($_SERVER['DOCUMENT_ROOT'] . "/" . $_GET['r']); } else { require_once($_SERVER['DOCUMENT_ROOT'] . '/unhandled.php'); } break; endswitch; ?> |
|
|||
|
On Mon, 5 May 2008 01:46:27 -0700 (PDT),
"celalo@gmail.com" <celalo@gmail.com> wrote: >Hi all, > >I am pretty much a PHP developer and I have a new idea for my website. >To implement the new idea I guess I need some basic configuration on >apache. >I have my index.php and everything runs depend on that file. Now I >want to manage any other requests on root directory other than the >index.php is handled. >For example: >for now, www.mydomain.com/index.php?foo=bar etc. works as expected >but I want any other requests like www.mydomain.com/bla, www.mydomain.com/qwerty, >www.mydomain.com/awsome, www.mydomain.com/danger are hadled somehow. >I suppose there should be a solution like handling any requests "which >is not handled as usual" >for example if I have some php file in some directory like >www.mydomain.com/somedir/somefile.php it should be run as expected but >lets say if I don't have "thisfiledoesntexist" in my directory >structure like www.mydomain.com/thisfiledoesntexist, this request >should be handled by lets say another php script called www.mydomain.com/unhandled.php > >can you suggest anything? You could try with the ErrorDocument directive: ErrorDocument 404 /unhandled.php ErrorDocument 404 http://www.mydomain.com/unhandled.php >Cheers >Baris HTH -- ( Kees ) c[_] Build a fire for a man and he will be warm for a day, but set fire to that man and he will be warm forever! (Sun Tzu) (#443) |
| Thread Tools | |
| Display Modes | |
|
|