DataRater Posted July 23, 2008 Share Posted July 23, 2008 I'm using apache to map something like www.something.com/firstpage/ to index.php in the top web directory. I also want to map www.something.com/secondpage/ to index.php inside index.php I want to be able to say if www.something.com/firstpage/ then include firstpage.php or if www.something.com/secondpage/ then include secondpage.php Have you any idea how I can find the original request i.e. www.something.com/firstpage/ from inside index.php? Quote Link to comment Share on other sites More sharing options...
elflacodepr Posted July 23, 2008 Share Posted July 23, 2008 so you mean you want to include the link to www.something.com/firstpage/ in www.something.com/secondpage/ and viceversa? Quote Link to comment Share on other sites More sharing options...
DataRater Posted July 23, 2008 Author Share Posted July 23, 2008 NO. I just want to know from inside index.php what the originating URL was. Quote Link to comment Share on other sites More sharing options...
DataRater Posted July 23, 2008 Author Share Posted July 23, 2008 I think I need a get_uri class. Any ideas? Quote Link to comment Share on other sites More sharing options...
sbunse Posted July 23, 2008 Share Posted July 23, 2008 hi, i'm not sure, but this info could be available as $_SERVER['REQUEST_URI'], if not and you're using mod_rewrite for your redirect, you could pass the originating url as query parameter to index.php. hope this helps, stefan Quote Link to comment Share on other sites More sharing options...
DataRater Posted July 23, 2008 Author Share Posted July 23, 2008 Hi stefan, Yeah those are a good ideas. Is $_SERVER['REQUEST_URI'] the URI before the rewite or after? I'll have to investigate that one. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted July 23, 2008 Share Posted July 23, 2008 Hi stefan, Yeah those are a good ideas. Is $_SERVER['REQUEST_URI'] the URI before the rewite or after? I'll have to investigate that one. It is after the rewrite. Can you show me your rewrite rules. Quote Link to comment Share on other sites More sharing options...
sbunse Posted July 24, 2008 Share Posted July 24, 2008 Hi DataRater, ok, if $_SERVER['REQUEST_URI'] is after the rewrite i would suggest passing the url as query parameter. A common pattern (to me, at least) is a rewrite config like this in an .htaccess file: <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] </IfModule> The two conditions check if there is a physical file or directory matching the url, if so no rewrite takes place, otherwise the request is rewritten to index.php and the original request path is passed as get parameter 'url' to index.php. Cheers, Stefan Quote Link to comment Share on other sites More sharing options...
DataRater Posted July 24, 2008 Author Share Posted July 24, 2008 Stefan, Excellent. Thanks. :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.