Sorry for the newbie question, but I've only been at PHP for a couple of
days, and I'm trying to get some stuff done as fast as possible. I'm an
experienced ASP.NET programmer, and am trying to find some equivalent
stuff in PHP.
In ASP.NET there is a method called Server.Transfer which transfers the
request to a different page from the one that the user requested, but
without doing a redirect. The user gets sent headers as though they were
seeing the page they requested.
Does PHP have such a function? I have seen the function...
header('Location: page.php');
...but these seems to be a redirect, which is not the same thing. I
don't want the headers altered as I want the search engines to see the
page with the original URL.
TIA for any help.
--
Alan Silver
(anything added below this line is nothing to do with me)
No, it doesn't. But I wish it did.
You could emulate it with CURL, but that's about all.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstu...@attglobal.net
==================
Shame.
>You could emulate it with CURL, but that's about all.
Thanks, but it looks OTT for the simple use I have in mind.
Thanks for the reply
Am I totally missing something simple here?
<?php>
// make sure no output has occurred, especially headers
if (whatever)
{
include 'the other page';
exit;
}
<?>
--
Richard.
include()
--
gosha bine
makrell ~ http://www.tagarga.com/blok/makrell
php done right ;) http://code.google.com/p/pihipi
Didn't work. I'm using Wordpress on a Windows platform, and I want to
use a permalink structure that gives blog links like
http://www.fred.com/a-blog-post instead of http://www.fred.com/?p=3 as
the former is much more search engine friendly. As I'm on Windows, I
don't have the .htaccess file where I could add the code to do the URL
rewriting, so I'm looking for other ways to do this. As this "blog" (it
isn't really) is only going to have a small number of pages, I was
hoping I could just set up a file that would be called from
http://www.fred.com/a-blog-post and have it send out the content of
http://www.fred.com/?p=3 instead. I tried include() but it didn't work.
Thanks anyway. I think it's going to be easier to copy the resulting
HTML into a static page and have that instead!
.htaccess and mod_rewrite work just fine in windows version of apache.
Are you using apache?
That doesn't redirect - as the op requested.
No. Server.Transfer is IIS' way of doing URL rewriting. PHP, being
originally developed for Apache, leaves URL rewriting to the HTTP
server. So what you need to do is to set up a rewrite rule. If you
are using Apache, you already have everything you need for that. If
you are using IIS, there are add-on modules that allow you to do URL
rewriting. I use ISAPI_Rewrite on one of my development servers:
>From your later message, I understand you are using WordPress.
WordPress' .htaccess file is not very complicated; it basically boils
down to this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
and the above in all likelihood can be ported over to ISAPI_Rewrite.
Cheers,
NC
Thanks for the reply. Given the simple nature of what I'm trying to do,
this is going to be OTT for the job. Useful to know in case I need it
for others though.
Ta ra
Nope, using IIS, and there are loads of ASP.NET sites already there, so
I wouldn't even think of switching servers now.
Thanks anyway
That's the difference. I've got one vps on Windows. All the rest are
Linux. The Windows VPS requires 4x the memory, 50% faster CPU - and
over twice the monthly cost of the Linux servers to do the same job.
And even then it's slower.
We're in the process of converting the last customer from ASP to PHP
now. Then even that one will be gone.
Horses for course I suppose. I'm very happy with my current set up. I
run my own server, so cost isn't an issue, and I'm very happy with IIS
and ASP.NET. I haven't used PHP enough to compare, so I'm not saying
ASP.NET is better, just that I'm very happy with it.
Thanks for the reply.