Forum Moderators: coopster
function requested_page()
{
$protocol = ((int) $_SERVER['SERVER_PORT'] === 443)? 'https://' : 'http://';
$current_page = $protocol . $_SERVER['HTTP_HOST'] . ((!empty($_SERVER['REQUEST_URI']))? $_SERVER['REQUEST_URI'] : '');return $current_page;
}
The PHP poll lives in poll_include.php. This poll lives on the right rail of my page, right_rail_include.html. right_rail_include.html contains an include to poll_include.php.
Let's say the page that is calling this right_rail_include.html is index.php?u=username&many=otherparams&may=exist, however the mod_rewrite is accepting that index page as: /index/username/other/exist
So when I goto http://example.com/index/username/other/exist I see the poll living in the right rail. On this page, the VOTE or VIEW RESULTS links point to http://example.com/right_rail_include.html?poll=27&results=1#poll
I'm using $SERVER['URI_REQUEST'], is there any predefined PHP function to get the URL after the mod_rewrite has taken place, so I can refresh this page successfully?
MANY Thanks!
[edited by: coopster at 5:31 pm (utc) on Jan. 31, 2007]
[edit reason] generalized domain [/edit]
the VOTE or VIEW RESULTS links contain http://example.com/right_rail_include.html?poll=27&results=1#poll
If that is the published link then that is the link that is going to show up in the address bar and the resource at that link will be displayed in the browser, unless you are doing some form of external redirection.
Perhaps you can clarify a bit more what is going on ...
What does the link look like that you are clicking?
What do you expect to show in the address bar after clicking the link?
The page that I am on in the browser window displays: http://example.com/index/username/other/exist
So the link for View Results SHOULD point to (and be displayed in the browser window after page load):
http://example.com/index/username/other/?poll=27&results=1#poll
However, the ACTUAL link that is on the button (the bug) is pointing to is:
http://example.com/right_rail_include.html?poll=27&results=1#poll
So I'm assuming $_SERVER[URI_REQUEST] is grabbing this included file before the URLs have been rewritten. Is there a predefined PHP variable that will grab the URL from the browser window (after rewrite) and then I can add?poll=27&results=1#poll to the end.
RewriteRule ^([^0-9]+/c/[^/]+)/?([0-9]*)/?$ /index.php?w=$1&p=$2 [L]
So it will allow users to goto:
[mydomain.com...]
and actually load the index.php page filling the "w" param.
However, the ACTUAL link that is on the button (the bug) is pointing to is:
http://example.com/right_rail_include.html?poll=27&results=1#poll
What is the exact PHP code you are using to build the link in this button? Can you paste it here? By the way, it is REQUEST_URI, not URI_REQUEST. I realize this may only be a typo here as you key into the forum discussion but it is going to be an issue if you are trying to use that in your actual PHP code.
In my poll include I am simply using <?= $_SERVER[PHP_SELF]?> to reference the page inside the link tag on the View Results button.
On static pages (where the URL is not being re-written) this works fine. But on any pages that are using mod_rewrite it grabs the location of the right_rail_include.html file.
The reason I used PHP_SELF was because it dropped the params at the end of the URL, REQUEST_URI kept the original params on there (after page load), and when I added additional params to the end of it I had two sets of the same params on the URL. (sorry why am I typing so confusing today?)
But both generated the same URL or path, that is the right_rail_include.php. Any other ideas/methods to try and get the exact address that is displayed in the browser's address bar?
This doesn't work because local filepaths don't use query strings:
include('/path/to/local/file.php?query=string&is=not&allowed=here');
This does work if url wrappers [us2.php.net] are enabled:
include('http://example.com/file.php?query=string&is=not&allowed=here');
What happens though is the file.php that is being 'included' is actually being requested and fetched from your website so it's REQUEST_URI is the one with the query string. To address this, just call includes that expect $_GET parameters like so:
$_GET['query'] = 'string';
$_GET['is'] = 'definitely';
$_GET['allowed'] = 'here';
include('/path/to/local/file.php');
Just be careful to avoid overwriting $_GET values that are in use on your main script. :)