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? Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/ 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? Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-597598 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. Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-597599 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? Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-597647 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 Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-597655 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. Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-597664 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. Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-597714 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 Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-598328 Share on other sites More sharing options...
DataRater Posted July 24, 2008 Author Share Posted July 24, 2008 Stefan, Excellent. Thanks. :-) Link to comment https://forums.phpfreaks.com/topic/116218-solved-apache-to-php/#findComment-598526 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.